題目鏈接:https://codeforces.com/gym/102021/attachments
題意:給出一個,你需要找到兩個數,,滿足。
解題心得:仔細觀察枚舉的數字不可能很大,直接暴力就可以了
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 6;
ll n;
ll q_pow(ll x, ll y) {
ll ans = 1;
for(int i=1;i<=y;i++) {
ans *= x;
}
return ans;
}
int main()
{
scanf("%lld", &n);
for(ll i=2;i<=60;i++) {
ll sum = 0;
for(ll j=1;;j++) {
sum += q_pow(j, i);
if(sum == n) {
printf("%lld %lld\n", i+1, j);
return 0;
}
if(sum > n) break;
}
}
printf("impossible\n");
return 0;
}