結果

問題 No.2754 Cumulate and Drop
ユーザー PyonPyon
提出日時 2024-05-10 23:17:00
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 664 bytes
コンパイル時間 3,320 ms
コンパイル使用メモリ 274,008 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-20 07:31:45
合計ジャッジ時間 4,954 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <atcoder/dsu>
#include <atcoder/segtree>
using namespace atcoder;
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
using vi = vector<int>; 
using vvi = vector<vi>; 
using li =vector<ll>;
using lli=vector<li>;
using si =vector<char>;
using ssi =vector<si>;
const long long INF = 1e18;
const long long MOD=998244353;
int main() { ll n;
cin>>n;ll ans=0;
if(n==2){ll a,b;cin>>a>>b;cout<<(a+b)%MOD;return 0;}
rep(i,0,n){ll a;cin>>a;a%=MOD;
if(i==0||i==1){ll b=n*(n-1)/2-1;b%=MOD;ans+=a*b;ans%=MOD;}
	else {ll b=(n-i)*(n-i+1)/2;b%=MOD;MOD;ans+=a*(n-i)*b;ans%=MOD;}
}
cout<<ans;
}
0