結果

問題 No.1105 Many Triplets
ユーザー 37zigen37zigen
提出日時 2020-07-04 00:25:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,430 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 12,004 KB
実行使用メモリ 70,828 KB
最終ジャッジ日時 2023-10-17 06:39:44
合計ジャッジ時間 18,708 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,430 ms
42,176 KB
testcase_01 AC 481 ms
42,268 KB
testcase_02 AC 486 ms
42,268 KB
testcase_03 AC 484 ms
42,268 KB
testcase_04 AC 487 ms
42,268 KB
testcase_05 AC 485 ms
42,268 KB
testcase_06 AC 479 ms
42,268 KB
testcase_07 AC 488 ms
42,268 KB
testcase_08 AC 484 ms
42,268 KB
testcase_09 AC 479 ms
42,268 KB
testcase_10 AC 477 ms
42,268 KB
testcase_11 AC 481 ms
42,268 KB
testcase_12 AC 484 ms
42,268 KB
testcase_13 AC 476 ms
42,268 KB
testcase_14 AC 479 ms
42,268 KB
testcase_15 AC 478 ms
42,268 KB
testcase_16 AC 480 ms
42,268 KB
testcase_17 AC 475 ms
42,268 KB
testcase_18 AC 480 ms
42,268 KB
testcase_19 AC 480 ms
42,268 KB
testcase_20 AC 480 ms
42,268 KB
testcase_21 AC 478 ms
42,268 KB
testcase_22 AC 482 ms
42,268 KB
testcase_23 AC 486 ms
42,268 KB
testcase_24 AC 484 ms
42,268 KB
testcase_25 AC 490 ms
42,268 KB
testcase_26 AC 484 ms
42,268 KB
testcase_27 AC 476 ms
70,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
MOD=10**9+7

def mul(a,b):
    c=np.dot(a,b)
    for i in range(len(c)):
        for j in range(len(c[i])):
            c[i][j]%=MOD
    return c

N=int(input())
A,B,C=map(int,input().split())

a=np.array([[1,-1,0],[0,1,-1],[-1,0,1]],dtype=np.int64)
vec=np.array([[A],[B],[C]],dtype=np.int64)
mat=np.eye(3,dtype=np.int64)
N=N-1

while N>0:
    if N%2==1:
        mat=mul(mat, a)
    a=mul(a,a)
    N//=2
vec=mul(mat,vec)
print(vec[0][0],vec[1][0],vec[2][0])
0