結果

問題 No.2111 Sum of Diff
ユーザー kotatsugamekotatsugame
提出日時 2022-10-28 21:28:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 356 bytes
コンパイル時間 600 ms
コンパイル使用メモリ 66,496 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2023-09-20 04:12:57
合計ジャッジ時間 2,852 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,476 KB
testcase_02 AC 77 ms
5,136 KB
testcase_03 AC 54 ms
4,888 KB
testcase_04 AC 13 ms
4,416 KB
testcase_05 AC 78 ms
5,156 KB
testcase_06 AC 77 ms
5,144 KB
testcase_07 AC 21 ms
4,488 KB
testcase_08 AC 28 ms
4,736 KB
testcase_09 AC 7 ms
4,380 KB
testcase_10 AC 9 ms
4,484 KB
testcase_11 AC 38 ms
4,860 KB
testcase_12 AC 37 ms
4,648 KB
testcase_13 AC 25 ms
4,548 KB
testcase_14 AC 64 ms
5,004 KB
testcase_15 AC 74 ms
5,108 KB
testcase_16 AC 33 ms
4,628 KB
testcase_17 AC 77 ms
5,148 KB
testcase_18 AC 26 ms
4,552 KB
testcase_19 AC 59 ms
5,068 KB
testcase_20 AC 77 ms
5,376 KB
testcase_21 AC 4 ms
4,500 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
int N,A[2<<17];
mint p2[2<<17];
main()
{
	cin>>N;
	p2[0]=1;
	for(int i=1;i<=N;i++)p2[i]=p2[i-1]*2;
	mint ans=0,prv=0,pc=0;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		ans-=(pc*A[i]+prv)*p2[N-i-1];
		prv-=A[i]*p2[i];
		pc+=p2[i];
	}
	cout<<ans.val()<<endl;
}
0