QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#65060 | #5103. Fair Division | littlefermat | WA | 3ms | 3516kb | C++14 | 810b | 2022-11-26 22:03:53 | 2022-11-26 22:03:55 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fast ios::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
using namespace std;
const ll INF = 1e18;
ld power(ll a, ll b){
if(b==0)return 1;
if(b%2==0)return power(a*a, b/2);
return a*power(a*a, b/2);
}
ll n,m;
ld c;
int main(){
fast;
cin>>n>>m;
if(n>60)cout<<"impossible";
else{
ll maxi = floor(pow(10, 18.0/(n-1)));
for(int i=2;i<maxi; i++){
for(int j=i-1; j>0; j--){
c = power(i,n)-power(j,n);
c/=(i-j);
if(c<=INF && m%((ll)c)==0){
cout<<i-j<<" "<<i;
return 0;
}
}
}
cout<<"impossible";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 3468kb
input:
13 382475111752106101
output:
17 28
result:
ok single line: '17 28'
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 3516kb
input:
59 576460752303423487
output:
impossible
result:
wrong answer 1st lines differ - expected: '1 2', found: 'impossible'