結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
newlife171128
|
| 提出日時 | 2018-01-27 20:53:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 672 bytes |
| コンパイル時間 | 1,610 ms |
| コンパイル使用メモリ | 158,136 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 05:25:42 |
| 合計ジャッジ時間 | 1,908 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <utility>
typedef long long ll;
using namespace std;
typedef pair<int, int> P;
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(){
int x=0,n=0;
cin>>x>>n;
ll ans=0;
for(int i=0; i<n; i++){
ll tmp;
cin>>tmp;
ans += mod_pow(x,tmp,1000003);
}
cout<<ans%1000003<<endl;
return 0;
}
newlife171128