QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#87885#5103. Fair DivisionzokerWA 12ms7872kbPython3407b2023-03-14 18:07:032023-03-14 18:07:05

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:07:05]
  • 评测
  • 测评结果:WA
  • 用时:12ms
  • 内存:7872kb
  • [2023-03-14 18:07:03]
  • 提交

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 = 3000
if n > 60:
	print("impossible")
	exit(0)
	
for q in range(2, N):
	for p in range(q - 1, 0, -1):
		t = (q ** n - p ** n) // (q - p)
		
		if (t  > m):
			break
		if(m % t == 0):
			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: 12ms
memory: 7872kb

input:

13 382475111752106101

output:

impossible

result:

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