結果
問題 | No.16 累乗の加算 |
ユーザー | b1ue |
提出日時 | 2018-04-13 22:47:46 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 17 ms / 5,000 ms |
コード長 | 483 bytes |
コンパイル時間 | 76 ms |
コンパイル使用メモリ | 10,900 KB |
実行使用メモリ | 7,904 KB |
最終ジャッジ日時 | 2023-09-09 04:43:05 |
合計ジャッジ時間 | 1,064 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
7,784 KB |
testcase_01 | AC | 16 ms
7,864 KB |
testcase_02 | AC | 17 ms
7,868 KB |
testcase_03 | AC | 16 ms
7,868 KB |
testcase_04 | AC | 15 ms
7,784 KB |
testcase_05 | AC | 16 ms
7,736 KB |
testcase_06 | AC | 16 ms
7,904 KB |
testcase_07 | AC | 16 ms
7,856 KB |
testcase_08 | AC | 16 ms
7,852 KB |
testcase_09 | AC | 16 ms
7,784 KB |
testcase_10 | AC | 16 ms
7,852 KB |
testcase_11 | AC | 16 ms
7,780 KB |
testcase_12 | AC | 16 ms
7,784 KB |
testcase_13 | AC | 15 ms
7,720 KB |
コンパイルメッセージ
Main.py:10: SyntaxWarning: "is" with a literal. Did you mean "=="? if y is 0:
ソースコード
def exps_input(exps): return [int(e) for e in exps.split(' ')] mod = 1_000_003 def pow_2(x, y): K = 1 if y is 0: return 1 while y > 1: if y % 2 == 0: x = x ** 2 % mod y = y // 2 else: K = K * x % mod x = x ** 2 % mod y = (y - 1) // 2 return K * x % mod sum = 0 base = int(input().split(' ')[0]) for exp in exps_input(input()): sum += pow_2(base, exp) print(sum % mod)