結果
問題 |
No.16 累乗の加算
|
ユーザー |
|
提出日時 | 2018-09-02 11:03:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 946 bytes |
コンパイル時間 | 669 ms |
コンパイル使用メモリ | 77,124 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-24 17:25:56 |
合計ジャッジ時間 | 1,344 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 WA * 10 |
ソースコード
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <numeric> #include <string> using namespace std; int mod = (int)(1e6 + 3); int ceil(int a, int b){ if (a % b){ return a/b + 1; }else return a/b; } typedef unsigned long long ull; ull pow(ull p, ull n) { ull w = 1; for (ull i = 1ULL << (sizeof(ull)*8-1); i != 0; i >>= 1) { if ((n & i) == 0) { w *= w; } else { w *= w * p; } } return w; } ull modpow(ull p, ull n, ull m) { ull w = 1; for (ull i = 1ULL << (sizeof(ull)*8-1); i != 0; i >>= 1) { if ((n & i) == 0) { w *= w; } else { w *= w * p; } w %= m; } return w; } int main(){ int x,n; cin >> x >> n; vector<int> arr; while (n--){ int t; cin >> t; arr.push_back(t); } int ans = 0; for(auto e:arr){ ans += modpow(x,e,mod); } cout << ans << endl; }