QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#70708 | #5103. Fair Division | nvmdava | WA | 2ms | 3376kb | C++20 | 912b | 2023-01-07 16:14:00 | 2023-01-07 16:14:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
ll m;
cin>>m;
for(ll q = 1; q < 4000; q++) {
for(ll p = q - 1; p > 0; --p) {
if(__gcd(p, q) > 1) continue;
ll s = 1;
ll t = 1;
bool lim = 0;
for(int i = 1; i < n; ++i) {
if(t > m / p || s > m / q) {
lim = 1;
break;
}
t *= p;
s = s * q + t;
}
if(lim) continue;
cout<<q - p<<' '<<q<<' '<<s<<'\n';
if(m % s == 0) {
cout<<q - p<<' '<<q;
return 0;
}
}
}
cout<<"impossible";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3376kb
input:
13 382475111752106101
output:
1 2 8191 1 3 1586131 2 3 797161 1 4 65514541 3 4 22369621 1 5 1153594261 2 5 609554401 3 5 406898311 4 5 305175781 1 6 11839990891 5 6 2612138803 1 7 83828316391 2 7 47834153641 3 7 32273967181 4 7 24221854021 5 7 19377800443 6 7 16148168401 1 8 452866803481 3 8 182845036921 5 8 109950843913 7 8 785...
result:
wrong answer 1st lines differ - expected: '17 28', found: '1 2 8191'