結果

問題 No.1136 Four Points Tour
ユーザー 37zigen
提出日時 2020-07-28 14:36:39
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 474 ms / 2,000 ms
コード長 291 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 44,316 KB
最終ジャッジ日時 2024-06-28 20:41:16
合計ジャッジ時間 20,030 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
MOD=10**9+7
a=np.array([[0,1],[3,2]],dtype=np.int64)
def pow_mat(a,n):
    ret=np.eye(2,dtype=np.int64)
    while n>0:
        if n%2==1:
            ret=np.dot(ret,a)%MOD
        a=np.dot(a,a)%MOD
        n//=2
    return ret
n=int(input())
a=pow_mat(a,n)
print(a[0][0])
0