QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#87769 | #5103. Fair Division | zoker# | WA | 21ms | 8056kb | Python3 | 544b | 2023-03-14 09:36:35 | 2023-03-14 09:36:39 |
Judging History
answer
import math
def ok(n, m, p, q):
if (n >= 60):
return False
calc = 0
for i in range(0, n):
calc = calc + (q ** i) * (p ** (n - i - 1))
for i in range(1, n + 1):
t = (q ** (n - i)) * (p ** (i - 1)) * m
if (t % calc != 0):
return False
return True
n, m = map(int, input().split())
N = 2000
for q in range(2, N):
for p in range(q - 1, 0, -1):
g = math.gcd(p,q)
if g != 1:
continue
if (q ** n - p ** n > m):
break
if(ok(n, m, p, q)):
print(q - p, q)
exit(0)
print("impossible")
详细
Test #1:
score: 0
Wrong Answer
time: 21ms
memory: 8056kb
input:
13 382475111752106101
output:
impossible
result:
wrong answer 1st lines differ - expected: '17 28', found: 'impossible'