Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <cmath>
- using namespace std;
- int main()
- {
- fstream iof{ "input.txt", ios::in };
- unsigned N;
- iof >> N;
- iof.close();
- unsigned maxpot = 1, maxbase = sqrt(N);
- for (unsigned M = 2; M <= maxbase; M++)
- {
- unsigned pot = M * M;
- while(pot * M <= N)
- pot *= M;
- if (pot > maxpot)
- maxpot = pot;
- if (pot == N) break;
- }
- iof.open("output.txt", ios::out);
- iof << maxpot;
- iof.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement