結果
問題 |
No.16 累乗の加算
|
ユーザー |
![]() |
提出日時 | 2020-06-13 21:02:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 672 bytes |
コンパイル時間 | 1,460 ms |
コンパイル使用メモリ | 165,320 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 21:11:05 |
合計ジャッジ時間 | 2,209 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } ll MOD = 1000003; ll powmod(ll a, ll b){ if(b == 0) return 1; if(b & 1) { return a * powmod(a, b - 1) % MOD; } else { ll d = powmod(a, b / 2) % MOD; return d * d % MOD; } } int main(){ cin.tie(0); ios::sync_with_stdio(false); ll x, n; cin >> x >> n; ll ans = 0; rep(i, n){ ll a; cin >> a; ans += powmod(x, a); ans %= MOD; } cout << ans << endl; }