結果
| 問題 |
No.1343 Dividing Digit
|
| コンテスト | |
| ユーザー |
sten_san
|
| 提出日時 | 2021-01-16 13:08:29 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 65 ms / 2,000 ms |
| コード長 | 880 bytes |
| コンパイル時間 | 2,187 ms |
| コンパイル使用メモリ | 194,784 KB |
| 最終ジャッジ日時 | 2025-01-17 21:40:23 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> using lqueue = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using gqueue = priority_queue<T, vector<T>, less<T>>;
int main() {
auto mpow = [](int64_t a, int64_t b, int64_t c) {
int64_t ans = 1;
while (b) {
if (b & 1) {
ans = (ans * a) % c;
}
a = (a * a) % c;
b >>= 1;
}
return ans;
};
int n, k; cin >> n >> k;
vec<int> a(n);
for (auto &e : a) cin >> e;
reverse(begin(a), end(a));
int64_t ans = 0, mod = accumulate(begin(a), end(a), int64_t(0));
for (int i = 0; i < n; ++i) {
ans += a[i] * mpow(k, i, mod);
ans %= mod;
}
cout << ans << endl;
}
sten_san