結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-04-13 22:06:13 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 401 bytes |
| コンパイル時間 | 230 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 33,236 KB |
| 最終ジャッジ日時 | 2024-06-26 21:42:35 |
| 合計ジャッジ時間 | 7,209 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 TLE * 1 -- * 11 |
コンパイルメッセージ
Main.py:8: SyntaxWarning: "is" with 'int' literal. Did you mean "=="? if n is 0: Main.py:10: SyntaxWarning: "is" with 'int' literal. Did you mean "=="? if n % 2 is 0:
ソースコード
def exps_input(exps):
return [int(e) for e in exps.split(' ')]
def pow_2(x, n):
if n < 0:
return pow(1 / x, -n)
if n is 0:
return 1
if n % 2 is 0:
return pow_2(x ** 2, n // 2)
else:
return x * pow_2(x, n - 1)
sum = 0
mod = 1_000_003
base = int(input().split(' ')[0])
for exp in exps_input(input()):
sum += pow_2(base, exp)
print(sum % mod)