QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#265764 | #5103. Fair Division | juampi | TL | 0ms | 0kb | Python3 | 847b | 2023-11-25 20:55:17 | 2023-11-25 20:55:18 |
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))
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)
except Exception:
print("impossible")
详细
Test #1:
score: 0
Time Limit Exceeded
input:
13 382475111752106101
output:
17 28 impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossib...