結果
| 問題 | No.2111 Sum of Diff |
| コンテスト | |
| ユーザー |
ぷら
|
| 提出日時 | 2022-10-28 23:33:24 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 78 ms / 2,000 ms |
| コード長 | 643 bytes |
| 記録 | |
| コンパイル時間 | 1,316 ms |
| コンパイル使用メモリ | 212,124 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-28 09:58:44 |
| 合計ジャッジ時間 | 3,351 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 998244353;
long long modpow(long long a,long long b) {
long long ans = 1;
while(b) {
if(b & 1) {
(ans *= a) %= mod;
}
(a *= a) %= mod;
b /= 2;
}
return ans;
}
int main() {
int N;
cin >> N;
vector<int>a(N);
for(int i = 0; i < N; i++) {
cin >> a[i];
}
int ans = 0;
for(int i = 0; i < N; i++) {
ans += a[i]*modpow(2,N-i-1)%mod;
if(ans >= mod) ans -= mod;
ans += (mod-a[i])*modpow(2,i)%mod;
if(ans >= mod) ans -= mod;
}
cout << ans << endl;
}
ぷら