結果
問題 | 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 = 1000003def binary_exponent(x, exponent):sum_values = 1quotient = exponentsquare_num = xwhile quotient > 0:quotient, mod = divmod(quotient, 2)if mod == 1:sum_values *= square_numsquare_num = pow(square_num, 2) % Mreturn sum_valuesif __name__ == '__main__':xN = list(map(int, input().split()))x = xN[0]N = xN[1]exponent_list = list(map(int, input().split()))sum_values = 0for exponent in exponent_list:sum_values += binary_exponent(x, exponent)print(sum_values % M)