QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#356614#5103. Fair DivisionTWTP_TCTFWA 56ms3852kbC++14955b2024-03-18 04:09:542024-03-18 04:09:54

Judging History

你现在查看的是最新测评结果

  • [2024-03-18 04:09:54]
  • 评测
  • 测评结果:WA
  • 用时:56ms
  • 内存:3852kb
  • [2024-03-18 04:09:54]
  • 提交

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'