QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#356614 | #5103. Fair Division | TWTP_TCTF | WA | 56ms | 3852kb | C++14 | 955b | 2024-03-18 04:09:54 | 2024-03-18 04:09:54 |
Judging History
answer
#include<iostream>
#include <bits/stdc++.h>
#define ld long double
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 2e3 + 9, MOD = 998244353;
bool check(ll n, ll m, ll p, ll q) {
__int128 pqn = 1, qn = 1;
for (int i = 1; i <= n; i++) {
pqn *= p + q;
qn *= q;
if (m * p < pqn - qn)return false;
}
__int128 cur = m * p;
return cur % (pqn - qn) == 0;
}
void doWork() {
ll m, n;
cin >> n >> m;
for (int q = 1; q <= 4000; q++) {
for (int p = 1; p < q; p++) {
if (check(n, m, p, q - p)) {
cout << p << " " << q;
return;
}
}
}
cout << "impossible";
}
int main() {
IO
int t = 1;
// cin >> t;
for (int i = 1; i <= t; i++) {
// cout << "Case #" << i << ": ";
doWork();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
input:
13 382475111752106101
output:
17 28
result:
ok single line: '17 28'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
59 576460752303423487
output:
1 2
result:
ok single line: '1 2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
15 227368755046033249
output:
13 14
result:
ok single line: '13 14'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
27 72027091647987988
output:
1 4
result:
ok single line: '1 4'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
12 817283057828223168
output:
10 17
result:
ok single line: '10 17'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
40 279103330129289325
output:
1 2
result:
ok single line: '1 2'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
9 200754090585004509
output:
27 31
result:
ok single line: '27 31'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
13 145272043713167318
output:
11 19
result:
ok single line: '11 19'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
13 330339892079732537
output:
3 5
result:
ok single line: '3 5'
Test #10:
score: -100
Wrong Answer
time: 56ms
memory: 3620kb
input:
8 518312274023062851
output:
impossible
result:
wrong answer 1st lines differ - expected: '35 81', found: 'impossible'