結果
問題 | No.16 累乗の加算 |
ユーザー |
![]() |
提出日時 | 2019-10-22 14:59:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 854 bytes |
コンパイル時間 | 1,478 ms |
コンパイル使用メモリ | 166,724 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 01:36:57 |
合計ジャッジ時間 | 2,116 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define int long long#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)#define itn int#define all(x) (x).begin(),(x).end()#define F first#define S secondconst long long INF = 1LL << 60;const int MOD = 1000003;template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }const int MAX = 510000;int power(int x, int n) {int ret = 1;while(n > 0) {if(n & 1) (ret *= x) %= MOD;(x *= x) %= MOD;n >>= 1;}return ret;}signed main(void){int x,n; cin>>x>>n;int ans = 0;rep(i,n){int a; cin>>a;ans += power(x, a);ans %= MOD;}cout<<ans<<endl;}