結果

問題 No.320 眠れない夜に
ユーザー ckawatakckawatak
提出日時 2019-04-30 14:07:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 1,281 ms
コンパイル使用メモリ 86,428 KB
実行使用メモリ 71,272 KB
最終ジャッジ日時 2023-08-28 17:03:54
合計ジャッジ時間 5,330 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,152 KB
testcase_01 AC 73 ms
70,684 KB
testcase_02 AC 71 ms
71,188 KB
testcase_03 AC 73 ms
71,156 KB
testcase_04 AC 71 ms
70,956 KB
testcase_05 AC 72 ms
70,856 KB
testcase_06 AC 73 ms
71,192 KB
testcase_07 AC 73 ms
70,852 KB
testcase_08 AC 74 ms
70,784 KB
testcase_09 AC 72 ms
70,856 KB
testcase_10 AC 73 ms
70,764 KB
testcase_11 AC 72 ms
70,848 KB
testcase_12 AC 72 ms
71,200 KB
testcase_13 AC 71 ms
71,272 KB
testcase_14 AC 71 ms
70,952 KB
testcase_15 AC 69 ms
71,112 KB
testcase_16 AC 71 ms
71,148 KB
testcase_17 AC 73 ms
70,708 KB
testcase_18 AC 72 ms
71,028 KB
testcase_19 AC 73 ms
70,956 KB
testcase_20 AC 70 ms
70,844 KB
testcase_21 AC 72 ms
71,156 KB
testcase_22 AC 71 ms
70,716 KB
testcase_23 AC 69 ms
71,272 KB
testcase_24 AC 69 ms
71,104 KB
testcase_25 AC 70 ms
70,836 KB
testcase_26 AC 73 ms
71,180 KB
testcase_27 AC 71 ms
70,788 KB
testcase_28 AC 71 ms
70,784 KB
testcase_29 AC 72 ms
70,808 KB
testcase_30 AC 74 ms
70,792 KB
testcase_31 AC 73 ms
70,704 KB
testcase_32 AC 70 ms
70,980 KB
testcase_33 AC 70 ms
70,804 KB
testcase_34 AC 68 ms
70,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = list(map(int, input().split()))

def fibo(n):
    numbers = [0 for _ in range(N)]
    numbers[0] = 1
    numbers[1] = 1
    for i in range(2,n):
        numbers[i] = numbers[i-1] + numbers[i-2]
    return numbers

numbers = fibo(N)
diff = numbers[N-1] - M

if diff == 0:
    print(0)
    exit(0)
    
if diff < 0:
    print(-1)
    exit(0)

count = 0
for i in reversed(range(0,N-2)):
    if 0 <= diff - numbers[i]:
        diff = diff - numbers[i]
        count = count + 1
        if diff == 0:
            break
            
print(count)        
0