QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#557713 | #5103. Fair Division | evirir | WA | 0ms | 3856kb | C++20 | 1.3kb | 2024-09-11 11:06:03 | 2024-09-11 11:06:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define pb push_back
using ll = long long;
using ii = pair<ll, ll>;
using ld = long double;
const int MAXN = 1005;
using i128 = __int128;
int main()
{
cin.tie(0)->sync_with_stdio(0);
ll n, m; cin >> n >> m;
fore(q,2,MAXN)
{
{
bool ok = 1;
ll qq = 1;
// a * b > c <=> a > floor(c / b)
forn(i, 0, n - 1)
{
if (qq > m / q)
{
ok = 0;
break;
}
qq *= q;
}
if (qq > m / (q - 1)) ok = 0;
if (!ok)
continue;
}
fore(p,1,q-1)
{
i128 qq = 1;
i128 pp = 1;
fore(i,1,n)
{
qq *= q;
pp *= p;
}
if (m % (qq - pp) == 0)
{
cout << p << ' ' << q << '\n';
return 0;
}
}
}
cout << "impossible\n";
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3856kb
input:
13 382475111752106101
output:
impossible
result:
wrong answer 1st lines differ - expected: '17 28', found: 'impossible'