結果
| 問題 | No.1299 Random Array Score |
| コンテスト | |
| ユーザー |
nok0
|
| 提出日時 | 2020-11-19 10:16:32 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 2,000 ms |
| コード長 | 485 bytes |
| 記録 | |
| コンパイル時間 | 2,794 ms |
| コンパイル使用メモリ | 194,164 KB |
| 最終ジャッジ日時 | 2025-01-16 01:40:26 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d%lld", &n, &k);
| ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:21:31: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | for(auto &v : a) scanf("%d", &v);
| ~~~~~^~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
const int mod = 998244353;
long long modpow(int n, long long k) {
long long ret = 1, mul = n;
while(k > 0) {
if(k & 1) ret *= mul, ret %= mod;
mul *= mul, mul %= mod;
k >>= 1;
}
return ret;
}
int main() {
int n;
long long k;
scanf("%d%lld", &n, &k);
std::vector<int> a(n);
for(auto &v : a) scanf("%d", &v);
long long res = std::accumulate(a.begin(), a.end(), 0ll) % mod;
res *= modpow(2, k);
printf("%lld\n", res % mod);
return 0;
}
nok0