結果
| 問題 |
No.1343 Dividing Digit
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-23 16:09:10 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 530 bytes |
| コンパイル時間 | 4,283 ms |
| コンパイル使用メモリ | 249,804 KB |
| 最終ジャッジ日時 | 2025-02-20 13:23:51 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
int N, K, A[101010];
ll sum, ans, powK[101010];
int main() {
cin >> N >> K;
for (int i = N; i >= 1; i--) {
cin >> A[i];
sum += A[i];
}
powK[1] = 1;
for (int i = 2; i <= N; i++) {
powK[i] = (powK[i - 1] * K) % sum;
}
for (int i = 1; i <= N; i++) {
ans = (ans + (A[i] * powK[i]) % sum) % sum;
}
//cout << sum << endl;
cout << ans << endl;
return 0;
}