結果

問題 No.1105 Many Triplets
ユーザー 37zigen37zigen
提出日時 2020-07-04 04:55:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 499 ms / 2,000 ms
コード長 374 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 11,864 KB
実行使用メモリ 42,248 KB
最終ジャッジ日時 2023-10-17 12:03:31
合計ジャッジ時間 16,407 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

def mul(a,b):
    return 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