結果
問題 |
No.16 累乗の加算
|
ユーザー |
|
提出日時 | 2021-01-16 22:42:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 516 bytes |
コンパイル時間 | 1,841 ms |
コンパイル使用メモリ | 165,564 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-28 09:17:38 |
合計ジャッジ時間 | 2,631 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; ll mod = 1000003; ll modpow(ll a,ll b){ ll ans = 1; a %= mod; while(b){ if(b&1) ans = ans * a % mod; a = a * a % mod; b >>= 1; } return ans; } int main(){ cin.tie(0); ios::sync_with_stdio(0); ll x,N; cin >> x >> N; ll ans = 0; rep(i,N){ ll a; cin >> a; ans = (ans + modpow(x, a)) % mod; } cout << ans << '\n'; }