結果
問題 | No.16 累乗の加算 |
ユーザー |
|
提出日時 | 2017-12-10 21:17:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 631 bytes |
コンパイル時間 | 1,648 ms |
コンパイル使用メモリ | 166,228 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 05:24:39 |
合計ジャッジ時間 | 2,314 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include <bits/stdc++.h>#define FOR(i,a,b) for(int i = (a); i < (b); ++i)#define REP(i,n) FOR(i,0,n)#define SZ(n) (int)(n).size()#define ALL(n) (n).begin(), (n).end()#define MOD 1000003#define INF 100000000using namespace std;typedef long long LL;typedef vector<int> VI;typedef pair<int, int> PI;LL modp(LL a, LL b) {if (b == 0) return 1;if (b == 1) return a;if (b % 2 == 1) return (a * modp(a, b - 1)) % MOD;return (modp(a, b / 2) * modp(a, b / 2)) % MOD;}int main() {int x, n;cin >> x >> n;LL ans = 0;REP(i, n) {int a;cin >> a;ans += modp(x, a);}cout << ans % MOD << endl;return 0;}