結果
問題 | No.16 累乗の加算 |
ユーザー |
![]() |
提出日時 | 2015-07-17 04:37:29 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 385 bytes |
コンパイル時間 | 403 ms |
コンパイル使用メモリ | 55,148 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-26 04:57:29 |
合計ジャッジ時間 | 1,030 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include<iostream>using namespace std;typedef long long LL;const int mod = 1000003;LL powmod(LL x, int e){LL r = 1;while (e){if (e&1) r = (r*x) % mod;x = (x*x) % mod;e >>= 1;}return r;}int main(){LL x; int n;cin >> x >> n;LL ans = 0;for (int i = 0; i < n; i++){int a; cin >> a;ans += powmod(x, a);}ans %= mod;cout << ans << endl;return 0;}