QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#536599 | #5103. Fair Division | RngBased# | WA | 0ms | 3732kb | C++20 | 1.1kb | 2024-08-29 14:53:53 | 2024-08-29 14:53:53 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
const ll big = 2e18;
ll safe_mul(ll a, ll b)
{
if (big / b < a)
return big;
else
return a * b;
}
ll n, m, pw[5005][35];
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n >> m;
if (n >= 30)
{
cout << "impossible\n";
return 0;
}
for (ll q = 1; q <= 4000; q++)
{
pw[q][0] = 1;
for (int i = 1; i < n; i++)
pw[q][i] = safe_mul(pw[q][i - 1], q);
for (ll rp = 1; rp < q; rp++)
{
ll p = q - rp;
ll sum = 0;
for (int i = 0; i < n; i++)
sum = min(big, sum + safe_mul(pw[p][i], pw[q][n - i - 1]));
if (m % sum == 0)
{
cout << rp << ' ' << q << '\n';
return 0;
}
}
}
cout << "impossible\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3732kb
input:
13 382475111752106101
output:
17 28
result:
ok single line: '17 28'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3676kb
input:
59 576460752303423487
output:
impossible
result:
wrong answer 1st lines differ - expected: '1 2', found: 'impossible'