QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#408701 | #5103. Fair Division | berarchegas | WA | 0ms | 3764kb | C++14 | 1.3kb | 2024-05-10 21:35:16 | 2024-05-10 21:35:18 |
Judging History
answer
#include <bits/stdc++.h>
#define O_O
using namespace std;
using ll = long long;
#define int ll
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ff first
#define ss second
mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 5;
const int INF = 1e9;
int n, m;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin>> n>> m;
vector<__int128> vec{1};
for(int a=2;; a++)
{
bool passou = false;
__int128 pa = 1;
for(int i=0; i<n; i++)
{
pa *= a;
if(pa - vec.back() > m)
{
passou = true;
break;
}
}
if(passou)
break;
// cout<< a<< " "<< (long long)pa<< endl;
vec.push_back(pa);
}
for(int i=0; i<vec.size(); i++)
{
for(int j=i-1; j>=0; j--)
{
__int128 qn = vec[i], qmpn = vec[j];
int q = i+1;
int qmp = j+1;
int p = q - qmp;
if(((__int128)m * p) % (qn - qmpn) == 0)
{
cout<< p<< " "<< q<< "\n";
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: 3764kb
input:
13 382475111752106101
output:
impossible
result:
wrong answer 1st lines differ - expected: '17 28', found: 'impossible'