結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,932 KB
testcase_01 AC 17 ms
8,028 KB
testcase_02 AC 16 ms
7,956 KB
testcase_03 AC 16 ms
7,932 KB
testcase_04 AC 16 ms
7,960 KB
testcase_05 AC 16 ms
7,928 KB
testcase_06 AC 16 ms
7,892 KB
testcase_07 AC 17 ms
7,956 KB
testcase_08 AC 17 ms
7,952 KB
testcase_09 AC 17 ms
7,996 KB
testcase_10 AC 17 ms
7,912 KB
testcase_11 AC 16 ms
7,952 KB
testcase_12 AC 17 ms
7,972 KB
testcase_13 AC 16 ms
7,960 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(int(ans % 1000003))
0