結果

問題 No.2111 Sum of Diff
ユーザー yamakeyamake
提出日時 2022-10-28 23:01:08
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 912 bytes
コンパイル時間 4,482 ms
コンパイル使用メモリ 260,520 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 06:13:47
合計ジャッジ時間 7,343 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 144 ms
4,380 KB
testcase_03 AC 97 ms
4,376 KB
testcase_04 AC 20 ms
4,376 KB
testcase_05 AC 146 ms
4,376 KB
testcase_06 AC 144 ms
4,376 KB
testcase_07 AC 35 ms
4,380 KB
testcase_08 AC 47 ms
4,380 KB
testcase_09 AC 10 ms
4,380 KB
testcase_10 AC 13 ms
4,380 KB
testcase_11 AC 68 ms
4,380 KB
testcase_12 AC 66 ms
4,376 KB
testcase_13 AC 43 ms
4,380 KB
testcase_14 AC 118 ms
4,380 KB
testcase_15 AC 139 ms
4,376 KB
testcase_16 AC 59 ms
4,376 KB
testcase_17 AC 145 ms
4,380 KB
testcase_18 AC 44 ms
4,376 KB
testcase_19 AC 108 ms
4,376 KB
testcase_20 AC 145 ms
4,376 KB
testcase_21 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define debug(output) if(debugFlag)cout<<#output<<"= "<<output<<"\n";
using lint = long long;
typedef pair<int,int> P;
const bool debugFlag=true;
const lint linf=1.1e18;const int inf=1.01e9;
constexpr int MOD=1000000007;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }

#include<atcoder/all>
using namespace atcoder;
using mint = modint998244353;

signed main(){
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    mint res=0;
    mint ni=2;
    rep(i,n){
        res+=ni.pow(i)*a[i]*(ni.pow(n-i-1)-1);
        res-=(ni.pow(i)-1)*a[i]*ni.pow(n-i-1);
    }
    cout<<res.val()<<"\n";
    return 0;
}
0