結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-01-11 11:13:03 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 5,000 ms |
| コード長 | 607 bytes |
| コンパイル時間 | 164 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-06-26 05:25:32 |
| 合計ジャッジ時間 | 1,253 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
# -*- coding: utf-8 -*-
M = 1000003
def binary_exponent(x, exponent):
sum_values = 1
quotient = exponent
square_num = x
while quotient > 0:
quotient, mod = divmod(quotient, 2)
if mod == 1:
sum_values *= square_num
square_num = pow(square_num, 2) % M
return sum_values
if __name__ == '__main__':
xN = list(map(int, input().split()))
x = xN[0]
N = xN[1]
exponent_list = list(map(int, input().split()))
sum_values = 0
for exponent in exponent_list:
sum_values += binary_exponent(x, exponent)
print(sum_values % M)