結果
問題 | No.16 累乗の加算 |
ユーザー |
![]() |
提出日時 | 2019-04-27 13:47:42 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 411 bytes |
コンパイル時間 | 1,261 ms |
コンパイル使用メモリ | 159,188 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 19:41:21 |
合計ジャッジ時間 | 1,880 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;ll MOD=1000003;ll x,N;vector<ll> a(110);ll mod_pow(ll x,ll n,ll mod){ll res=1;while(n>0){if(n&1)res=res*x%mod;x=x*x%mod; n>>=1;}return res;}int main(){cin >> x >> N;for(int i=0;i<N;i++)cin >> a[i];long long ans=0;for(int i=0;i<N;i++){ans=(ans+mod_pow(x,a[i],MOD))%MOD;}cout << ans << endl;}