QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#87769#5103. Fair Divisionzoker#WA 21ms8056kbPython3544b2023-03-14 09:36:352023-03-14 09:36:39

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:36:39]
  • 评测
  • 测评结果:WA
  • 用时:21ms
  • 内存:8056kb
  • [2023-03-14 09:36:35]
  • 提交

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")

Details

Tip: Click on the bar to expand more detailed information

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'