結果

問題 No.16 累乗の加算
ユーザー szkakeszkake
提出日時 2015-08-29 11:24:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 475 bytes
コンパイル時間 615 ms
コンパイル使用メモリ 10,500 KB
実行使用メモリ 7,944 KB
最終ジャッジ日時 2023-09-08 11:45:59
合計ジャッジ時間 1,435 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,796 KB
testcase_01 AC 16 ms
7,840 KB
testcase_02 AC 17 ms
7,768 KB
testcase_03 AC 16 ms
7,772 KB
testcase_04 AC 16 ms
7,800 KB
testcase_05 AC 16 ms
7,820 KB
testcase_06 AC 16 ms
7,720 KB
testcase_07 AC 16 ms
7,944 KB
testcase_08 AC 16 ms
7,820 KB
testcase_09 AC 17 ms
7,904 KB
testcase_10 AC 16 ms
7,764 KB
testcase_11 AC 16 ms
7,836 KB
testcase_12 AC 16 ms
7,820 KB
testcase_13 AC 16 ms
7,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding:utf-8 -*-
# http://yukicoder.me/problems/42
M = 1000003

def my_pow(x, n):
    ret = 1
    while 0 < n:
        if n % 2 == 0:
            x *= x % M
            n >>= 1
        else:
            ret *= x % M
            n -= 1
    return ret
if __name__ == '__main__':
    x, n = map(int, input().split())
    an = map(int, input().split())
    answer = 0
    x %= 1000003
    for a in an:
        p = my_pow(x, a)
        answer += p % M
    print(answer % M)
0