結果
問題 | No.16 累乗の加算 |
ユーザー | kn451t |
提出日時 | 2021-11-20 17:48:19 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 73 ms / 5,000 ms |
コード長 | 1,856 bytes |
コンパイル時間 | 762 ms |
コンパイル使用メモリ | 86,596 KB |
実行使用メモリ | 71,432 KB |
最終ジャッジ日時 | 2023-09-02 13:25:10 |
合計ジャッジ時間 | 2,243 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
71,096 KB |
testcase_01 | AC | 71 ms
71,432 KB |
testcase_02 | AC | 71 ms
71,328 KB |
testcase_03 | AC | 71 ms
71,148 KB |
testcase_04 | AC | 71 ms
71,144 KB |
testcase_05 | AC | 70 ms
71,288 KB |
testcase_06 | AC | 71 ms
71,388 KB |
testcase_07 | AC | 71 ms
71,248 KB |
testcase_08 | AC | 72 ms
71,256 KB |
testcase_09 | AC | 72 ms
71,184 KB |
testcase_10 | AC | 72 ms
71,244 KB |
testcase_11 | AC | 71 ms
71,228 KB |
testcase_12 | AC | 73 ms
71,260 KB |
testcase_13 | AC | 70 ms
71,284 KB |
ソースコード
MOD = 1000003 # 適宜変更 class ModInt: def __init__(self, x): self.x = x % MOD def __str__(self): return str(self.x) __repr__ = __str__ def __add__(self, other): return ( ModInt(self.x + other.x) if isinstance(other, ModInt) else ModInt(self.x + other) ) def __sub__(self, other): return ( ModInt(self.x - other.x) if isinstance(other, ModInt) else ModInt(self.x - other) ) def __mul__(self, other): return ( ModInt(self.x * other.x) if isinstance(other, ModInt) else ModInt(self.x * other) ) def __truediv__(self, other): return ( ModInt( self.x * pow(other.x, MOD - 2, MOD) ) if isinstance(other, ModInt) else ModInt(self.x * pow(other, MOD - 2, MOD)) ) def __pow__(self, other): return ( ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else ModInt(pow(self.x, other, MOD)) ) __radd__ = __add__ def __rsub__(self, other): return ( ModInt(other.x - self.x) if isinstance(other, ModInt) else ModInt(other - self.x) ) __rmul__ = __mul__ def __rtruediv__(self, other): return ( ModInt( other.x * pow(self.x, MOD - 2, MOD) ) if isinstance(other, ModInt) else ModInt(other * pow(self.x, MOD - 2, MOD)) ) def __rpow__(self, other): return ( ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else ModInt(pow(other, self.x, MOD)) ) x,n=map(int,input().split()) a=[int(i) for i in input().split()] result=ModInt(0) for i in range(n): result+=ModInt(x)**a[i] print(result)