結果

問題 No.891 隣接3項間の漸化式
ユーザー k-kk-k
提出日時 2019-09-21 14:43:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 476 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 11,760 KB
実行使用メモリ 10,096 KB
最終ジャッジ日時 2023-10-19 02:29:19
合計ジャッジ時間 22,783 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,096 KB
testcase_01 AC 29 ms
10,096 KB
testcase_02 AC 30 ms
10,096 KB
testcase_03 AC 846 ms
10,096 KB
testcase_04 AC 1,661 ms
10,096 KB
testcase_05 AC 1,776 ms
10,096 KB
testcase_06 TLE -
testcase_07 AC 1,650 ms
10,096 KB
testcase_08 AC 1,452 ms
10,096 KB
testcase_09 AC 1,908 ms
10,096 KB
testcase_10 AC 351 ms
10,096 KB
testcase_11 AC 929 ms
10,096 KB
testcase_12 TLE -
testcase_13 AC 31 ms
10,096 KB
testcase_14 AC 30 ms
10,096 KB
testcase_15 AC 31 ms
10,096 KB
testcase_16 AC 903 ms
10,096 KB
testcase_17 AC 29 ms
10,096 KB
testcase_18 AC 30 ms
10,096 KB
testcase_19 AC 161 ms
10,096 KB
testcase_20 AC 30 ms
10,096 KB
testcase_21 AC 29 ms
10,096 KB
testcase_22 AC 250 ms
10,096 KB
testcase_23 AC 30 ms
10,096 KB
testcase_24 AC 30 ms
10,096 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def calc(a, b, n):
    """
    x_n を計算する
    """
    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        ret_i = 0
        ret_i1 = 1
        for i in range(n - 1):
            swap = a * ret_i1 + b * ret_i
            ret_i = ret_i1 
            ret_i1 = swap % (10 ** 9 + 7)
        return ret_i1

if __name__ == "__main__":
    input_line = input().split(" ")
    print(calc(int(input_line[0]), int(input_line[1]), int(input_line[2])))
0