QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#265758#5103. Fair DivisionjuampiTL 0ms0kbPython3903b2023-11-25 20:53:312023-11-25 20:53:31

Judging History

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

  • [2023-11-25 20:53:31]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-11-25 20:53:31]
  • 提交

answer

import math

while True:
    try:
        N, M = map(int, input().split())
        if N > 200:
            N = 200

        p, q = 0, 0
        pw = [0, 0]
        for q in range(2, int(1e6)):
            pw.append(math.pow(q, N))
            print(str(q)+"+"+str(q))
            for p in range(1, q):
                d = pw[q] - pw[q - p]
                if d > 1.1 * M * q:
                    if p == 1:
                        raise Exception
                    continue
                qp = 1
                pp = 1
                for i in range(N):
                    qp *= q
                for i in range(N):
                    pp *= (q - p)
                if M * p % (qp - pp) == 0:
                    raise StopIteration

        print(p, q)
    except StopIteration:
        print(p, q)
        continue
    except Exception:
        print("impossible")

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

13 382475111752106101

output:

2+2
3+3
4+4
5+5
6+6
7+7
8+8
9+9
10+10
11+11
12+12
13+13
14+14
15+15
16+16
17+17
18+18
19+19
20+20
21+21
22+22
23+23
24+24
25+25
26+26
27+27
28+28
17 28
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impos...

result: