結果
| 問題 | No.16 累乗の加算 |
| コンテスト | |
| ユーザー |
nenuon
|
| 提出日時 | 2017-06-18 16:23:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 805 bytes |
| コンパイル時間 | 712 ms |
| コンパイル使用メモリ | 89,372 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 05:23:43 |
| 合計ジャッジ時間 | 1,404 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define PI acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
//高速に累乗を計算
long long fastpow(long long base, long long e){
long long ans = 1;
for(long long p = base; e; e >>= 1, p = (p * p) % 1000003){
if(e & 1) ans = (ans * p) % 1000003;
}
return ans;
}
int main(){
ll x, n;
cin >> x >> n;
ll ans = 0;
FOR(i,0,n){
ll a;
cin >> a;
ans += fastpow(x, a);
ans %= 1000003;
}
cout << ans << endl;
}
nenuon