Guest User

Untitled

a guest
Feb 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int f(int a)
  5. {
  6.     int r=0, ha = a/2;
  7.     for(int i=2; a>1 && !r && i <= ha; i++)
  8.         while (a%i==0)
  9.             a /= i, r++;
  10.     return r;
  11. }
  12.  
  13. int main()
  14. {
  15.     int n,m,k=0,ok=1;
  16.     cin>>n;
  17.     m=n;
  18.     while (n >= 10)
  19.     {
  20.         k++;
  21.         n/=10;
  22.     }
  23.     n=m;
  24.     do{
  25.         n=(n%10)*pow(double(10),k)+n/10;
  26.         cout<<n<<' ';
  27.         if (f(n))
  28.             ok=0;
  29.     }while (n!=m);
  30.     if (ok)
  31.         cout<<"DA"<<endl;
  32.     else
  33.         cout<<"NU"<<endl;
  34.     return 0;
  35. }
Add Comment
Please, Sign In to add comment