結果
問題 | No.16 累乗の加算 |
ユーザー |
👑 ![]() |
提出日時 | 2020-10-06 20:39:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 481 bytes |
コンパイル時間 | 1,813 ms |
コンパイル使用メモリ | 167,056 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 02:59:25 |
合計ジャッジ時間 | 2,456 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include<bits/stdc++.h>using namespace std;using LL = long long;using ULL = unsigned long long;#define rep(i,n) for(int i=0; i<(n); i++)const ULL M = 1000003;ULL powm(ULL x, ULL i) {if (i == 0) return 1;ULL res = powm(x * x % M, i / 2);if (i % 2 == 1) res = res * x % M;return res;}int main() {ULL x, N; cin >> x >> N;ULL ans = 0;rep(i, N) { ULL a; cin >> a; ans += powm(x, a); }ans %= M;cout << ans << endl;return 0;}