結果
問題 | No.1299 Random Array Score |
ユーザー |
![]() |
提出日時 | 2021-02-24 13:14:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 86 ms / 2,000 ms |
コード長 | 811 bytes |
コンパイル時間 | 804 ms |
コンパイル使用メモリ | 76,892 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 14:29:00 |
合計ジャッジ時間 | 4,566 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>#include <map>using namespace std;using ll = long long;//const int mod = 1e9 + 7;const int mod = 998244353;const int INF = 100100100;ll gcd(ll a , ll b){if(a < b)swap(a , b);if(a % b == 0)return b;else return gcd(b , a % b);}ll modpow (ll a , ll b , ll m) {ll ret = 1;while (b > 0) {if (b & 1) {ret *= a;ret %= m;}a = a * a;a %= m;b >>= 1;}return ret;}int main(){int n; ll k;cin >> n >> k;vector<int> a(n);ll sum = 0;for (int i = 0; i < n; i++) {cin >> a[i];sum += a[i];sum %= mod;}ll ans = modpow((ll)2 , k , mod) * sum % mod;cout << ans << '\n';return 0;}