QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#114772#5322. Revenge of FibonacciPetroTarnavskyi#TL 0ms0kbPython3452b2023-06-23 15:55:152023-06-23 15:55:27

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-23 15:55:27]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-06-23 15:55:15]
  • 提交

answer

f0 = 1
f1 = 1
ans = {}
ans[1] = 0
for i in range(1, 100001):
	(f0, f1) = (f1, f0 + f1)
	if len(str(f1)) > 74:
		f0 = f0 // 10
		f1 = f1 // 10
	f0_str = str(f0)
	pref = 0
	for j in range(1, min(40, len(f0_str)) + 1):
		pref = 10 * pref + ord(f0_str[j - 1]) - ord('0')
		if pref not in ans:
			ans[pref] = i
tc = int(input())
for t in range(1, tc + 1):
	s = int(input())
	print("Case #", t, ": ", ans[s] if s in ans else -1, sep = '')

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

50000
792362991986528154794111338308492
439673290826407208
363566069103643927
617208990855375359
10923013836786367
12768656204
5278138430
3162806369255331536189
110441
228497727352029613251
7924171
56188963
71025506137142741639694
112631974340
1223041785964352220301
6132969058016461907372737549
9945...

output:


result: