Advertisement
a53

perfecte_2

a53
Feb 14th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include"iostream"
  2.  
  3. using namespace std;
  4.  
  5. typedef unsigned long long LL;
  6.  
  7. bool esteprim(LL a)
  8. {
  9. if(a < 2)
  10. return false;
  11. if(a == 2)
  12. return true;
  13. if((a & 1) == 0)
  14. return false;
  15. for(LL i=3 ; i*i<=a ; ++i)
  16. if(a % i == 0)
  17. return false;
  18. return true;
  19. }
  20. LL putere(LL baza, LL exponent)
  21. {
  22. LL rez = baza;
  23. for(LL i = 1 ; i < exponent ; ++i)
  24. rez *= baza;
  25. return rez;
  26. }
  27. int main()
  28. {
  29.  
  30. LL V[8]={}, k=0 , N, X[1000];
  31. for(LL y=1 ; y< 32 ; ++y)
  32. if(esteprim(putere(2, y)-1))
  33. V[k++]=(putere(2, y)-1)*putere(2,(y-1));
  34.  
  35. cin>>N;
  36.  
  37. for(int i=0 ; i< N ; ++i)
  38. cin>>X[i];
  39. for(int i=0 ; i< N ; ++i)
  40. {
  41. bool gasit = false;
  42. for(LL j=0 ; j< 8 ; ++j)
  43. if(X[i] == V[j])
  44. {
  45. cout<<"1 ";
  46. gasit = true;
  47. }
  48. if(!gasit)
  49. cout<<"0 ";
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement