結果

問題 No.16 累乗の加算
ユーザー Pump0129Pump0129
提出日時 2018-09-19 22:26:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 684 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 8,112 KB
最終ジャッジ日時 2023-09-25 10:16:36
合計ジャッジ時間 1,030 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,968 KB
testcase_01 AC 16 ms
7,900 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 15 ms
7,916 KB
testcase_12 WA -
testcase_13 AC 15 ms
7,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math


class No16:
    x = 0
    n = 0
    num_list = []

    def __init__(self):
        self.x, self.n = map(int, input().split(" "))
        self.num_list = list(map(int, input().split(" ")))

    def solve(self):
        ans = 0
        for y in self.num_list:
            ans += self.first_pow(self.x, y, 1000003)
        return ans

    def first_pow(self, x, y, m):
        if y == 0:
            return 1
        elif y % 2 == 0:
            return self.first_pow(x * x % m, y // 2, m)
        else:
            return x * self.first_pow(x, y - 1, m) % m


if __name__ == "__main__":
    que = No16()
    ans = que.solve()
    print(ans)
0