rafi1590

Light

Apr 17th, 2020
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. int light(int n){
  8.  
  9. int root = sqrt(n);
  10. int count = 0;
  11. for(int i =1;i<=root;i++){
  12. if(n%i==0){
  13. int div = n/i;
  14. if(div ==i){
  15. count += 1;
  16. }
  17. else{
  18. count += 2;
  19. }
  20. }
  21.  
  22. }
  23. if(count%2==0)
  24. return 0;
  25. else
  26. return 1;
  27.  
  28. }
  29.  
  30.  
  31.  
  32. int main(){
  33.  
  34. long long n;
  35.  
  36. while(1){
  37. cin >> n;
  38. if(n==0)
  39. break;
  40. else{
  41. int checker = light(n);
  42. if(checker==0)
  43. cout << "no" << '\n';
  44. else
  45. cout << "yes" << '\n';
  46. }
  47. }
  48.  
  49.  
  50.  
  51.  
  52.  
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment