結果

問題 No.1105 Many Triplets
ユーザー もりをもりを
提出日時 2020-07-03 22:32:39
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 787 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 81,616 KB
実行使用メモリ 79,164 KB
最終ジャッジ日時 2023-10-17 05:31:07
合計ジャッジ時間 3,918 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 36 ms
53,428 KB
testcase_21 AC 37 ms
53,428 KB
testcase_22 AC 36 ms
53,428 KB
testcase_23 AC 37 ms
53,428 KB
testcase_24 AC 38 ms
53,428 KB
testcase_25 AC 38 ms
53,428 KB
testcase_26 AC 36 ms
53,428 KB
testcase_27 AC 36 ms
53,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import cos

n = int(input())
a = list(map(int,input().split()))
M = 10 ** 9 + 7
# a,b,c = (1,0,0),(0,1,0),(0,0,1)

# def f(a,b):
    # return (a[0]-b[0],a[1]-b[1],a[2]-b[2])

p = [1, 1, 0, -3, -9, -18]
q = [-1, -2, -3, -3, 0, 9]
r = [0, 1, 3, 6, 9, 9]

def g(n, l):
    if n >= 6:
        return pow(M - 27, n // 6, M) * g(n - 6, l) % M
    return l[n] if l[n] >= 0 else M + l[n]

# for _ in range(10):
    # print(a, b, c)
    # print(a[2], end=" ")
    # a,b,c = f(a,b), f(b,c), f(c,a)
    # if _%6==0:
        # print()

ll = [g(n - 2, l) for l in (p, q, r)]
for _ in range(3):
    res = 0
    for j, i in enumerate(ll):
        res += i * a[j]
        res %= M
    print(res, end="")
    if _ == 2:
        print()
    else:
        print(' ',end="")
    a = a[1:] + [a[0]]
0