結果
問題 | No.16 累乗の加算 |
ユーザー |
|
提出日時 | 2018-04-13 22:47:46 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 33 ms / 5,000 ms |
コード長 | 483 bytes |
コンパイル時間 | 81 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-06-26 21:49:42 |
合計ジャッジ時間 | 1,162 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
コンパイルメッセージ
Main.py:10: SyntaxWarning: "is" with 'int' 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)