Advertisement
Guest User

Untitled

a guest
Oct 4th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. void analyse(int, int);
  8.  
  9. int main()
  10. {
  11.     ios_base::sync_with_stdio(false);
  12.     int zestawy;
  13.     cin >> zestawy;
  14.     cin.ignore();
  15.     std::string line;
  16.     int s, a;
  17.     int pos;
  18.     for (int i = 0; i < zestawy; i++)
  19.     {
  20.         getline(cin, line);
  21.         pos = line.find(" ");
  22.         a = stoi(line.substr(0, pos));
  23.         s = stoi(line.substr(pos));
  24.         analyse(a, s);
  25.         line.clear();
  26.     }
  27.    
  28.     cin.get();
  29.     cin.get();
  30.  
  31.     return 0;
  32. }
  33.  
  34. void analyse(int a, int s)
  35. {
  36.     int c = 0;
  37.     for (int i = a; i; i--)
  38.     {
  39.         c = pow(i, s);
  40.         if (!(a % c))
  41.         {
  42.             cout << i << " " << a / c << endl;
  43.             break;
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement