結果

問題 No.320 眠れない夜に
ユーザー ntudantuda
提出日時 2021-11-13 13:45:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 334 bytes
コンパイル時間 1,173 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 71,536 KB
最終ジャッジ日時 2023-08-18 05:47:33
合計ジャッジ時間 5,224 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,316 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 72 ms
71,368 KB
testcase_04 AC 74 ms
71,156 KB
testcase_05 AC 76 ms
71,072 KB
testcase_06 AC 77 ms
71,308 KB
testcase_07 AC 73 ms
71,304 KB
testcase_08 AC 72 ms
71,128 KB
testcase_09 AC 73 ms
71,048 KB
testcase_10 AC 73 ms
71,480 KB
testcase_11 AC 77 ms
71,492 KB
testcase_12 AC 78 ms
71,436 KB
testcase_13 AC 70 ms
71,056 KB
testcase_14 AC 77 ms
71,284 KB
testcase_15 AC 73 ms
71,284 KB
testcase_16 AC 72 ms
71,148 KB
testcase_17 AC 72 ms
71,212 KB
testcase_18 AC 77 ms
71,152 KB
testcase_19 AC 75 ms
71,232 KB
testcase_20 AC 73 ms
71,244 KB
testcase_21 AC 71 ms
71,324 KB
testcase_22 AC 73 ms
71,308 KB
testcase_23 WA -
testcase_24 AC 75 ms
71,372 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 71 ms
71,304 KB
testcase_29 AC 71 ms
71,284 KB
testcase_30 AC 70 ms
71,272 KB
testcase_31 AC 73 ms
71,088 KB
testcase_32 AC 76 ms
71,304 KB
testcase_33 AC 71 ms
71,296 KB
testcase_34 AC 77 ms
71,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

N,M = map(int,input().split())
fib = [0] * N
fib[0] = fib[1] = 1
for i in range(2,N):
    fib[i] = fib[i-1] + fib[i-2]
dif = fib[N-1] - M
if dif < 0:
    print(-1)
    sys.exit()
ans = 0
for i in reversed(range(1,N-1)):
    if dif >= fib[i]:
        dif -= fib[i]
        ans += 1
    if dif == 0:
        break
print(ans)
0