結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
saitaman
|
| 提出日時 | 2018-08-11 09:57:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 696 bytes |
| コンパイル時間 | 665 ms |
| コンパイル使用メモリ | 85,784 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-23 06:07:09 |
| 合計ジャッジ時間 | 1,461 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <unordered_map>
#include <utility>
#include <map>
#include <set>
using namespace std;
long long pow(long long x, long long n){
long long int ans = 1;
while(n > 0){
if(n&1){
ans *= x;
ans %= 1000003;
}
x = x * x % 1000003;
n >>= 1;
}
return ans;
}
int main(){
long long ans = 0;
long long x, n, a;
cin >> x >> n;
for(int i = 0; i < n; i++){
cin >> a;
ans += pow(x, a);
ans %= 1000003;
}
cout << ans << endl;
}
saitaman