結果

問題 No.320 眠れない夜に
ユーザー matsu7874matsu7874
提出日時 2015-12-13 00:31:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 368 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 10,560 KB
実行使用メモリ 8,008 KB
最終ジャッジ日時 2023-10-13 14:04:46
合計ジャッジ時間 1,788 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,948 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 14 ms
7,892 KB
testcase_04 AC 15 ms
7,728 KB
testcase_05 AC 13 ms
7,896 KB
testcase_06 AC 13 ms
7,780 KB
testcase_07 AC 13 ms
7,776 KB
testcase_08 AC 13 ms
7,892 KB
testcase_09 AC 14 ms
7,804 KB
testcase_10 AC 14 ms
7,728 KB
testcase_11 AC 14 ms
7,792 KB
testcase_12 AC 13 ms
7,740 KB
testcase_13 AC 13 ms
7,892 KB
testcase_14 AC 14 ms
7,908 KB
testcase_15 AC 13 ms
7,748 KB
testcase_16 AC 14 ms
7,708 KB
testcase_17 AC 14 ms
7,780 KB
testcase_18 AC 13 ms
7,732 KB
testcase_19 AC 14 ms
7,780 KB
testcase_20 AC 14 ms
7,784 KB
testcase_21 AC 14 ms
7,776 KB
testcase_22 AC 14 ms
7,788 KB
testcase_23 WA -
testcase_24 AC 13 ms
7,896 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 13 ms
7,936 KB
testcase_29 AC 14 ms
7,740 KB
testcase_30 AC 13 ms
7,776 KB
testcase_31 AC 13 ms
7,912 KB
testcase_32 AC 14 ms
7,852 KB
testcase_33 AC 13 ms
7,732 KB
testcase_34 AC 14 ms
7,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
fib = [0, 1, 1]
for i in range(N - 2):
    fib.append(fib[-1] + fib[-2])
diff = fib[N] - M
if diff < 0:
    print(-1)
elif diff == 0:
    print(0)
else:
    cnt = 0
    for i in range(N, 0, -1):
        if fib[i] <= diff:
            diff -= fib[i]
            cnt += 1
    if diff == 0:
        print(cnt)
    else:
        print(-1)
0