QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#768312 | #5103. Fair Division | uglasses | WA | 0ms | 3584kb | C++14 | 638b | 2024-11-21 09:05:09 | 2024-11-21 09:05:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m;
int p,q,r;
int ksm(int x,int y)
{
int res=1;
int z=x;
while(y)
{
if(y&1) res*=z;
z*=z;
y>>=1;
}
return res;
}
int gcd(int x,int y)
{
if(y==0) return x;
return gcd(y,x%y);
}
signed main()
{
// cout<<ksm(3,4);
cin>>n>>m;
for(int q=2;ksm(q,n)<=m;q++)
{
for(int p=1;p<q&&gcd(q,p)==1;p++)
{
__int128 sum=0;
for(int i=0;i<n;i++)
{
sum+=(__int128(ksm(q,i)*ksm(p,n-i-1)));
}
if(m%sum==0)
{
cout<<(q-p)<<" "<<q<<endl;
return 0;
}
}
}
cout<<"impossible\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3584kb
input:
13 382475111752106101
output:
impossible
result:
wrong answer 1st lines differ - expected: '17 28', found: 'impossible'