結果

問題 No.16 累乗の加算
ユーザー maatanbetamaatanbeta
提出日時 2017-04-28 16:04:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 652 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 10,800 KB
実行使用メモリ 8,156 KB
最終ジャッジ日時 2023-10-11 18:53:30
合計ジャッジ時間 1,328 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,932 KB
testcase_01 AC 16 ms
7,972 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 WA -
testcase_12 WA -
testcase_13 AC 16 ms
7,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import log10
x, N = map(int, input().split())
a = list(map(int, input().split()))
xp = 0
n = 1000003


def keta(x, a):
    ketasuu = int(a * log10(x)) + 1
    return ketasuu


def amari(x, a, n):
    global xp
    if keta(x, a) <= 9:
        return (x ** a) % n
    else:
        result = 0
        r = a // xp
        result = amari(j, r, n) * (x ** (a % xp) % n) % n
        return result


if x > 1:
    i = 0
    while(True):
        if x ** i > n:
            xp = i
            j = (x ** i) % n
            break
        i += 1

shiguma = 0
for i in range(N):
    shiguma += amari(x, a[i], n)
    shiguma = shiguma % n

print(shiguma)
0