Saleh127

spoj Psychon

Jul 8th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. #define maX 1000008
  7. vector<ll>p;
  8. bool marked[maX];
  9. void sieve()
  10. {
  11. p.push_back(2);
  12. for(ll i=4;i<=maX;i+=2)
  13. {
  14. marked[i]=1;
  15. }
  16. for(ll i=3;i<=maX;i+=2)
  17. {
  18. if(marked[i]==0)
  19. {
  20. p.push_back(i);
  21. for(ll j=i*i; j<=maX; j+=i+i)
  22. {
  23. marked[j]=1;
  24. }
  25. }
  26. }
  27. }
  28. int main()
  29. {
  30. fellow_junior
  31. sieve();
  32. test
  33. {
  34. ll a,c,d=0,e=0,f,i,j,k,l;
  35. cin>>a;
  36. for(i=0;i<p.size() && p[i]*p[i]<=a;i++)
  37. {
  38. if(a%p[i]==0)
  39. {
  40. c=0;
  41. while(a%p[i]==0)
  42. {
  43. c++;
  44. a/=p[i];
  45. }
  46. if(c%2) d++;
  47. else e++;
  48. }
  49. }
  50. if(a>1) d++;
  51.  
  52. if(e>d) cout<<"Psycho Number"<<endl;
  53. else cout<<"Ordinary Number"<<endl;
  54. }
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment