結果

問題 No.16 累乗の加算
ユーザー cherrypi59
提出日時 2018-10-01 07:04:00
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 378 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-10-12 09:27:02
合計ジャッジ時間 1,213 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

M = 10 ** 6 + 3


def mod_pow(x, n):
    res = 1
    while n:
        if n & 1:
            res = res * x % M
        x = x * x % M
        n >>= 1

    return res


def main():
    x, n = map(int, input().split())
    a = list(map(int, input().split()))

    ans = 0
    for i in a:
        ans = (ans+mod_pow(x, i)) % M

    print(ans)


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