結果

問題 No.1500 Super Knight
ユーザー googol_S0googol_S0
提出日時 2021-05-07 21:34:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 688 bytes
コンパイル時間 1,811 ms
コンパイル使用メモリ 86,220 KB
実行使用メモリ 76,240 KB
最終ジャッジ日時 2023-10-13 12:33:47
合計ジャッジ時間 6,216 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
70,996 KB
testcase_01 AC 87 ms
75,932 KB
testcase_02 AC 78 ms
76,192 KB
testcase_03 AC 79 ms
76,152 KB
testcase_04 AC 81 ms
76,076 KB
testcase_05 AC 79 ms
76,044 KB
testcase_06 AC 80 ms
75,988 KB
testcase_07 AC 79 ms
76,200 KB
testcase_08 AC 78 ms
76,224 KB
testcase_09 AC 81 ms
76,220 KB
testcase_10 AC 78 ms
76,196 KB
testcase_11 AC 80 ms
76,156 KB
testcase_12 AC 80 ms
76,144 KB
testcase_13 AC 79 ms
75,948 KB
testcase_14 AC 80 ms
76,088 KB
testcase_15 AC 81 ms
76,164 KB
testcase_16 AC 74 ms
71,268 KB
testcase_17 AC 80 ms
76,108 KB
testcase_18 AC 78 ms
76,132 KB
testcase_19 AC 79 ms
76,056 KB
testcase_20 AC 70 ms
71,088 KB
testcase_21 AC 79 ms
75,960 KB
testcase_22 AC 79 ms
76,096 KB
testcase_23 AC 79 ms
75,988 KB
testcase_24 AC 79 ms
76,240 KB
testcase_25 AC 79 ms
76,172 KB
testcase_26 AC 72 ms
71,176 KB
testcase_27 AC 82 ms
76,108 KB
testcase_28 AC 73 ms
71,252 KB
testcase_29 AC 79 ms
75,860 KB
testcase_30 AC 80 ms
76,128 KB
testcase_31 AC 81 ms
76,136 KB
testcase_32 AC 80 ms
76,200 KB
testcase_33 AC 81 ms
76,144 KB
testcase_34 AC 81 ms
76,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
mod=10**9+7
def m(a,b):
  r=[[0]*len(b[0]) for i in range(len(a))]
  for i in range(len(a)):
    for k in range(len(b)):
      for j in range(len(b[0])):
        r[i][j]=(r[i][j]+a[i][k]*b[k][j])%mod
  return r

def p(a,n):
  r=[[0]*len(a) for i in range(len(a))]
  b=[]
  for i in range(len(a)):
    r[i][i]=1
    b.append(a[i][:])
  l=n
  while l>0:
    if l&1:
      r=m(b,r)
    b=m(b,b)
    l>>=1
  return r

A=[[0]*6 for i in range(6)]
for i in range(5):
  A[i+1][i]=1
A[0][2]=1
A[0][1]=-3
A[0][0]=3
B=[[0]*6 for i in range(6)]
B[5][-1]=1
B[4][-1]=12
B[3][-1]=65
B[2][-1]=172
B[1][-1]=297
B[0][-1]=456
if N<=5:
  print(B[5-N][-1])
  exit()
print(m(p(A,N-5),B)[0][-1])
0