結果
| 問題 |
No.2111 Sum of Diff
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-29 02:20:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,815 bytes |
| コンパイル時間 | 1,600 ms |
| コンパイル使用メモリ | 169,404 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-06 04:43:24 |
| 合計ジャッジ時間 | 3,065 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | WA * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
template<typename T>bool chmax(T &a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a, const T& b){if(a>b){a=b;return true;}return false;}
const int mod = 998244353 ;
class mint {
long long x;
public:
mint(long long x=0) : x((x%mod+mod)%mod) {}
mint operator-() const {
return mint(-x);
}
mint& operator+=(const mint& a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint& a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint& a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint& a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint& a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint& a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
// for prime mod
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint& a) {
return (*this) *= a.inv();
}
mint operator/(const mint& a) const {
mint res(*this);
return res/=a;
}
friend ostream& operator<<(ostream& os, const mint& m){
os << m.x;
return os;
}
};
int main(){
int n;cin>>n;
vector<int> a(n);
rep(i,n){
cin>>a[i];
}
mint ans=0;
for(int i=0;i<=n-1;++i){
ans+=(a[i]*(1<<(n-(i+1))));
ans-=(a[i]*(1<<i));
}
cout<<ans<<endl;
}