QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#87883#5103. Fair DivisionzokerWA 10ms7936kbPython3442b2023-03-14 18:03:462023-03-14 18:03:48

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 18:03:48]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:7936kb
  • [2023-03-14 18:03:46]
  • 提交

answer

import math

def ok(n, m, p, q):
	if (n > 60):
		return False
	return m % ((p ** n - q ** n) // (p - q)) == 0
n, m = map(int, input().split())
N = 2000
if n > 60:
	print("impossible")
	exit(0)
	
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 * (q - p)):
			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: 10ms
memory: 7936kb

input:

13 382475111752106101

output:

impossible

result:

wrong answer 1st lines differ - expected: '17 28', found: 'impossible'