Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- void analyse(int, int);
- int main()
- {
- ios_base::sync_with_stdio(false);
- int zestawy;
- cin >> zestawy;
- cin.ignore();
- std::string line;
- int s, a;
- int pos;
- for (int i = 0; i < zestawy; i++)
- {
- getline(cin, line);
- pos = line.find(" ");
- a = stoi(line.substr(0, pos));
- s = stoi(line.substr(pos));
- analyse(a, s);
- line.clear();
- }
- cin.get();
- cin.get();
- return 0;
- }
- void analyse(int a, int s)
- {
- int c = 0;
- for (int i = a; i; i--)
- {
- c = pow(i, s);
- if (!(a % c))
- {
- cout << i << " " << a / c << endl;
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement