結果

問題 No.1136 Four Points Tour
ユーザー ThetaTheta
提出日時 2022-10-20 18:45:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 1,879 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-06-30 10:26:45
合計ジャッジ時間 2,643 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,880 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 33 ms
10,880 KB
testcase_03 AC 31 ms
10,752 KB
testcase_04 AC 31 ms
10,880 KB
testcase_05 AC 31 ms
10,752 KB
testcase_06 AC 30 ms
10,752 KB
testcase_07 AC 31 ms
11,008 KB
testcase_08 AC 31 ms
10,880 KB
testcase_09 AC 30 ms
10,880 KB
testcase_10 AC 31 ms
11,008 KB
testcase_11 AC 30 ms
11,008 KB
testcase_12 AC 33 ms
10,752 KB
testcase_13 AC 31 ms
10,880 KB
testcase_14 AC 30 ms
10,880 KB
testcase_15 AC 32 ms
10,880 KB
testcase_16 AC 31 ms
10,880 KB
testcase_17 AC 31 ms
10,880 KB
testcase_18 AC 31 ms
10,880 KB
testcase_19 AC 30 ms
10,880 KB
testcase_20 AC 31 ms
10,880 KB
testcase_21 AC 31 ms
10,752 KB
01_Sample03_evil.txt WA -
04_Rnd_large_evil1.txt AC 31 ms
10,752 KB
04_Rnd_large_evil2.txt AC 30 ms
10,880 KB
04_Rnd_large_evil3.txt AC 31 ms
10,880 KB
04_Rnd_large_evil4.txt AC 30 ms
10,752 KB
04_Rnd_large_evil5.txt AC 31 ms
10,880 KB
04_Rnd_large_evil6.txt AC 30 ms
10,880 KB
04_Rnd_large_evil7.txt AC 31 ms
10,880 KB
04_Rnd_large_evil8.txt AC 31 ms
10,752 KB
04_Rnd_large_evil9.txt AC 31 ms
10,880 KB
04_Rnd_large_evil10.txt AC 31 ms
10,880 KB
05_Rnd_huge_evil1.txt AC 31 ms
10,752 KB
05_Rnd_huge_evil2.txt WA -
05_Rnd_huge_evil3.txt WA -
05_Rnd_huge_evil4.txt WA -
05_Rnd_huge_evil5.txt WA -
05_Rnd_huge_evil6.txt WA -
05_Rnd_huge_evil7.txt WA -
99_evil_01.txt AC 30 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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())

    match N % 2:

        case 1:
            print(Modint(6) * ((9**(Modint(N//2)) - 1)/8))
        case 0:
            print(Modint(2) * ((9**(Modint(N//2)) - 1)/8) + 1)


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