結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-17 01:08:54 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 715 bytes |
| コンパイル時間 | 898 ms |
| コンパイル使用メモリ | 107,448 KB |
| 最終ジャッジ日時 | 2025-01-11 21:41:45 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
constexpr ll mod=1000003;
ll mod_pow(ll a,ll b){
a%=mod;
if(b==0)return 1;
if(b==1)return a;
ll res=mod_pow(a,b/2)%mod;
res*=res; res%=mod;
if(b%2)res*=a;
return res%mod;
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll res=0;
int x,n; cin >> x >> n;
while(n--){
int a; cin >> a;
(res+=mod_pow(x,a))%=mod;
}
cout << res << endl;
}