結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
mh72012246
|
| 提出日時 | 2016-11-16 12:47:38 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 960 bytes |
| コンパイル時間 | 1,322 ms |
| コンパイル使用メモリ | 78,208 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 05:18:15 |
| 合計ジャッジ時間 | 1,368 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#include <iostream>
#include <cmath>
#include <vector>
// #include <array>
#include <queue>
#include <set>
#include <map>
#include <sstream> // istringstream
#include <algorithm> // sort
#include <utility> // pair
#include <cfloat> // DBL_MAX
typedef long long ll;
using namespace std;
const ll diviser = 1000003;
ll power(ll m, ll e){
if(e==0){ return 1; }
if(e==1){ return m; }
if(e==2){ return m*m; }
ll tmp = power(m,e/2);
if(e%2==0){
return (tmp*tmp) % diviser;
} else {
return (tmp*tmp*m) % diviser;
}
}
int main(){
// input
ll X,N; // [10]
cin >> X >> N;
vector<int> As(N);
for(int i=0; i<N; i++){
cin >> As[i];
}
// main
sort(As.begin(), As.end(), greater<ll>());
vector<int> dif(N);
for(int i=0; i<N-1; i++){
dif[i] = As[i]-As[i+1];
} dif[N-1] = As[N-1];
ll res = 0;
for(int i=0; i<N; i++){
res = ((res+1)*power(X,dif[i])) % diviser;
}
cout << res << endl;
return 0;
}
mh72012246