結果

問題 No.1081 和の和
ユーザー ThetaTheta
提出日時 2022-10-21 11:28:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,875 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 8,476 KB
最終ジャッジ日時 2023-09-13 13:33:41
合計ジャッジ時間 1,328 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,316 KB
testcase_01 AC 17 ms
8,392 KB
testcase_02 AC 16 ms
8,456 KB
testcase_03 AC 16 ms
8,384 KB
testcase_04 AC 19 ms
8,476 KB
testcase_05 AC 16 ms
8,428 KB
testcase_06 AC 17 ms
8,436 KB
testcase_07 AC 20 ms
8,284 KB
testcase_08 AC 20 ms
8,432 KB
testcase_09 AC 21 ms
8,404 KB
testcase_10 AC 20 ms
8,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import pairwise


class Modint:

    MOD = int(1e9+7)

    def __init__(self, value: int) -> None:
        self.num = int(value) % self.MOD

    def __str__(self) -> str:
        return str(self.num)

    __repr__ = __str__

    def __add__(self, __x):
        if isinstance(__x, Modint):
            return Modint((self.num + __x.num))
        return Modint(self.num + __x)

    def __sub__(self, __x):
        if isinstance(__x, Modint):
            return Modint(self.num - __x.num)
        return Modint(self.num - __x)

    def __mul__(self, __x):
        if isinstance(__x, Modint):
            return Modint(self.num * __x.num)
        return Modint(self.num * __x)

    __radd__ = __add__
    __rmul__ = __mul__

    def __rsub__(self, __x):
        if isinstance(__x, Modint):
            return Modint(__x.num - self.num)
        return Modint(__x - self.num)

    def __pow__(self, __x):
        if isinstance(__x, Modint):
            return Modint(pow(self.num, __x.num, self.MOD))
        return Modint(pow(self.num, __x, self.MOD))

    def __rpow__(self, __x):
        if isinstance(__x, Modint):
            return Modint(pow(__x.num, self.num, self.MOD))
        return Modint(pow(__x, self.num, self.MOD))

    def __truediv__(self, __x):
        if isinstance(__x, Modint):
            return Modint(self.num * pow(__x.num, self.MOD - 2, self.MOD))
        return Modint(self.num * pow(__x, self.MOD - 2, self.MOD))

    def __rtruediv__(self, __x):
        if isinstance(__x, Modint):
            return Modint(__x.num * pow(self.num, self.MOD - 2, self.MOD))
        return Modint(__x * pow(self.num, self.MOD - 2, self.MOD))


def main():
    N = int(input())
    A = list(map(Modint, input().split()))

    while len(A) > 1:
        A = [elm1+elm2 for elm1, elm2 in pairwise(A)]

    print(A[0])


if __name__ == "__main__":
    main()
0