結果
問題 | No.16 累乗の加算 |
ユーザー |
![]() |
提出日時 | 2016-04-27 23:49:18 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,098 bytes |
コンパイル時間 | 874 ms |
コンパイル使用メモリ | 78,576 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 05:14:08 |
合計ジャッジ時間 | 1,809 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include <algorithm>#include <cmath>#include <cstring>#include <iostream>#include <map>#include <numeric>#include <queue>#include <set>#include <sstream>#include <stack>#include <string>#include <vector>#include <iterator>//#define pb push_back#define puts(x) cout << #x << " : " << x << endl;//#pragma GCC diagnostic ignored "-Wconversion"//#define REP(i,n) for (int i=0;i<(n);i++)//#define REPE(i,n) for (int i=0;i<=(n);i++)//#define init(a,b) memset((a), (b), (sizeof(a)));//#define PI 3.14159265//#define EPS (1e-10)//#define EQ(a,b) (abs((a)-(b)) < EPS)using namespace std;typedef long long ll;//#define int long longint dxy[] = {0, 1, 0, -1, 0};typedef pair<int, int> P;ll mod = 1000 * 1000 + 3;inline ll pow_mod(ll a, ll k, ll m) {ll r = 1;for (; k > 0; k >>= 1) {if (k & 1) (r *= a) %= m;(a *= a) %= m;}return r;}signed main() {ll x,n;cin>>x>>n;ll res = 0;while(n--){ll a;cin>>a;res += pow_mod(x, a, mod);res %= mod;}cout<<(res%mod)<<endl;return 0;}