結果

問題 No.1136 Four Points Tour
ユーザー flippergo
提出日時 2020-12-24 14:01:38
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 488 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 350 ms
コンパイル使用メモリ 20,568 KB
実行使用メモリ 34,416 KB
最終ジャッジ日時 2026-04-09 22:32:50
合計ジャッジ時間 26,542 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21 TLE * 2 -- * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import numpy as np
p = 10**9+7
I = np.array([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],dtype=np.int64)
def pow(A,n):
    if n==0:
        return I
    if n==1:
        return A
    if n%2==0:
        return (np.matmul(pow(A,n//2),pow(A,n//2)))%p
    else:
        return np.matmul(A,np.matmul(pow(A,(n-1)//2),pow(A,(n-1)//2))%p)%p
A = np.array([[0,1,1,1],[1,0,1,1],[1,1,0,1],[1,1,1,0]],dtype=np.int64)
N = int(input())
a = np.matmul(np.array([1,0,0,0],dtype=np.int64),pow(A,N))
print(a[0])
0