結果

問題 No.1105 Many Triplets
ユーザー 37zigen37zigen
提出日時 2020-07-04 00:29:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 479 ms / 2,000 ms
コード長 382 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 42,260 KB
最終ジャッジ日時 2023-10-17 06:41:39
合計ジャッジ時間 15,305 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 467 ms
42,260 KB
testcase_01 AC 476 ms
42,260 KB
testcase_02 AC 469 ms
42,260 KB
testcase_03 AC 467 ms
42,260 KB
testcase_04 AC 472 ms
42,260 KB
testcase_05 AC 479 ms
42,260 KB
testcase_06 AC 473 ms
42,260 KB
testcase_07 AC 474 ms
42,260 KB
testcase_08 AC 469 ms
42,260 KB
testcase_09 AC 469 ms
42,260 KB
testcase_10 AC 469 ms
42,260 KB
testcase_11 AC 468 ms
42,260 KB
testcase_12 AC 474 ms
42,260 KB
testcase_13 AC 472 ms
42,260 KB
testcase_14 AC 473 ms
42,260 KB
testcase_15 AC 472 ms
42,260 KB
testcase_16 AC 474 ms
42,260 KB
testcase_17 AC 472 ms
42,260 KB
testcase_18 AC 466 ms
42,260 KB
testcase_19 AC 470 ms
42,260 KB
testcase_20 AC 472 ms
42,260 KB
testcase_21 AC 471 ms
42,260 KB
testcase_22 AC 469 ms
42,260 KB
testcase_23 AC 466 ms
42,260 KB
testcase_24 AC 475 ms
42,260 KB
testcase_25 AC 473 ms
42,260 KB
testcase_26 AC 477 ms
42,260 KB
testcase_27 AC 477 ms
42,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def mul(a,b):
    return np.dot(a,b)%MOD

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&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