fork(3) download
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int ucln(int a, int b)
  6. {
  7. while (b!=0)
  8. {
  9. int x = a%b;
  10. a = b;
  11. b = x;
  12. }
  13. return a;
  14. }
  15.  
  16. int snt(int x)
  17. {
  18. if (x<2)
  19. return 0;
  20. for (int i=2; i<=sqrt(x); i++)
  21. if (x%i==0)
  22. return 0;
  23. return 1;
  24. }
  25.  
  26. int main()
  27. {
  28. int T;
  29. cin>>T;
  30. while(T--)
  31. {
  32. int x;
  33. cin>>x;
  34. int d = 0;
  35. for (int i=1; i<=x; i++)
  36. {
  37. if (ucln(i, x)==1)
  38. d++;
  39. }
  40. if (snt(d)==1)
  41. cout<<"1"<<endl;
  42. else
  43. cout<<"0"<<endl;
  44. }
  45. return 0;
  46. }
Success #stdin #stdout 0s 15240KB
stdin
2
2
3
stdout
0
1