QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#87753#5103. Fair Divisionzoker#WA 1335ms7984kbPython3527b2023-03-14 09:09:172023-03-14 09:09:19

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-14 09:09:19]
  • 评测
  • 测评结果:WA
  • 用时:1335ms
  • 内存:7984kb
  • [2023-03-14 09:09:17]
  • 提交

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'