QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#352607#5103. Fair DivisionPorNPtree#WA 2ms3740kbC++14764b2024-03-13 13:59:282024-03-13 13:59:28

Judging History

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

  • [2024-03-13 13:59:28]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3740kb
  • [2024-03-13 13:59:28]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

signed main()
{
    int n;
    long long m;
    scanf("%d%lld", &n, &m);
    if (n < 100) {
        for (int q = 2; q <= 100; ++q) {
            for (int p = 1; p < q; ++p) {
                long double t = (long double)p / q, now = (1 - t) / (1 - pow(t, n)) * m;
                int flg = (fabs(now - floor(now + 0.5)) < 1e-6);
                for (int z = 1; z < n && flg; ++z) {
                    now *= t;
                    flg &= (fabs(now - floor(now + 0.5)) < 1e-6);
                }
                if (flg) {
                    printf("%d %d\n", q - p, q);
                    return 0;
                }
            }
        }
    }
    puts("impossible");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3740kb

input:

13 382475111752106101

output:

impossible

result:

wrong answer 1st lines differ - expected: '17 28', found: 'impossible'