Advertisement
double_trouble

разлож

Nov 21st, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <cmath>
  5. #include <string>
  6. #include <algorithm>
  7. #include <string>
  8. #include <string.h>
  9.  
  10. #define F first
  11. #define S second
  12.  
  13.  
  14.  
  15. using namespace std;
  16.  
  17. vector <long long> p, b;
  18.  
  19. int main()
  20. {
  21.     ios_base::sync_with_stdio(0);
  22.     freopen("input.txt", "r", stdin);
  23.     freopen("output.txt", "w", stdout);
  24.     long long n;
  25.     cin >> n;
  26.     long long d = 2;
  27.     while (d * d <= n)
  28.     {
  29.         if (n % d == 0)
  30.         {
  31.             p.push_back(d);
  32.             int z = 0;
  33.             while (n % d == 0)
  34.             {
  35.                 z++;
  36.                 n /= d;
  37.             }
  38.             b.push_back(z);
  39.         }
  40.         if (d == 2)
  41.             d = 3;
  42.         else
  43.             d += 2;
  44.     }
  45. if (n >= 1)
  46. {
  47.     p.push_back(n);
  48.     b.push_back(1);
  49. }
  50. //cout << p.size() << " " << b.size() << endl;
  51. //for (int i = 0; i < p.size(); i++)
  52. //    cout << p[i] << " " << b[i] << endl;
  53. int k = p.size() - 1;
  54. //cout << b[k] << endl;
  55.     if (k > 0)
  56.     {
  57.         for (int i = 0; i < k; i++)
  58.             for (int j = 0; j < b[i]; j++)
  59.             cout << p[i] << "*";
  60.         for (int i = 0; i < b[k] - 1; i++)
  61.             cout << p[k] << "*";
  62.         cout << p[k];
  63.     }
  64.     else
  65.         {
  66.             for (int i = 0; i < b[0] - 1; i++)
  67.                 cout << p[0] << "*";
  68.             cout << p[0];
  69.         }
  70.  
  71.     return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement