QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#87753 | #5103. Fair Division | zoker# | WA | 1335ms | 7984kb | Python3 | 527b | 2023-03-14 09:09:17 | 2023-03-14 09:09:19 |
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(1, q):
g = math.gcd(p,q)
if g != 1:
continue
if(m % (q ** n - p ** n) ==0 and ok(n, m, p, q)):
print(q - p, q)
exit(0)
print("impossible")
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1335ms
memory: 7984kb
input:
13 382475111752106101
output:
impossible
result:
wrong answer 1st lines differ - expected: '17 28', found: 'impossible'