QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#391351 | #5103. Fair Division | surenjamts | WA | 0ms | 3648kb | C++14 | 1.1kb | 2024-04-16 15:46:08 | 2024-04-16 15:46:08 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
ll n, m;
ll zereg[1045][64];
bool check(int a, int b, int c){
if(a>c) return false;
double x, y, z, p;
x=a;
y=b;
z=c;
p=c/b;
if(x>p) return false;
else return true;
}
int of(int q){
ll p=1;
zereg[q][0]=1;
for(int i=1;i<n;i++){
if(check(p, q, m)){
p*=q;
zereg[q][i]=p;
} else return 0;
}
return p;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(NULL);
cin>>n>>m;
for(int i=0;i<64;i++){
zereg[1][i]=1;
}
for(int q=2;q<=1e4+1;q++){
ll z=of(q);
if(z!=0) {
for(int p=1;p<q;p++){
if(m%(q-p)==0){
ll rem=m/(q-p);
ll sum=0;
bool flag=true;
for(int i=0;i<n;i++){
sum+=zereg[p][i]*zereg[q][n-i-1];
// cout<<zereg[p][i]<<" "<<zereg[q][n-i-1]<<endl;
if(sum>rem) {
flag=false;
break;
}
}
if(flag && rem%sum==0){
cout<<q-p<<" "<<q<<endl;
return 0;
}
}
}
} else break;
}
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: 3648kb
input:
13 382475111752106101
output:
impossible
result:
wrong answer 1st lines differ - expected: '17 28', found: 'impossible'