asgarlikanan

https://www.e-olymp.com/az/problems/842

Aug 6th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
4CS 0.43 KB | None | 0 0
  1. /*
  2.     Author: Kanan Asgarli
  3.     https://www.e-olymp.com/az/problems/842
  4. */
  5. #include <iostream>
  6. #include <cmath>
  7. using namespace std;
  8. int n, f;
  9. int main()
  10. {
  11.     cin>>n;
  12.     for(int i = 2; i <= (int)sqrt(n); i++)
  13.         while( n % i == 0 ){
  14.             if( f == 0 )
  15.                 cout<<i;
  16.             else
  17.                 cout<<"*"<<i;
  18.             n = n / i;
  19.             f = 1;
  20.         }
  21.     if( n > 1 ){
  22.         if( f == 0 )
  23.             cout<<n;
  24.         else
  25.             cout<<"*"<<n;
  26.         }
  27.     cout<<endl;
  28.    
  29.     return 0;
  30. }
Add Comment
Please, Sign In to add comment