結果
問題 | No.1897 Sum of 2nd Max |
ユーザー |
|
提出日時 | 2022-04-28 10:14:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 62 ms / 2,000 ms |
コード長 | 917 bytes |
コンパイル時間 | 1,469 ms |
コンパイル使用メモリ | 167,396 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-28 07:54:02 |
合計ジャッジ時間 | 3,516 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
/*made in mrd*/ #include<bits/stdc++.h> using namespace std; const int N=2e5+10; const int mod=998244353; #define endl '\n' #define int long long #define mem(a,b) memset(a,b,sizeof a) #define fi first #define se second #define lu u<<1 #define ru u<<1|1 #define pb push_back #define bug1(x) cout<<x<<endl #define bug2(x,y) cout<<x<<' '<<y<<endl #define pii pair<int,int> #define bug3(x,y,z) cout<<x<<' '<<y<<' '<<z<<endl void init() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int qsm(int a,int b) { int res=1; while(b) { if(b&1) res=res*a%mod; b>>=1; a=a*a%mod; } return res; } signed main() { init(); int n,m; cin>>n>>m; int sum=0; for(int i=1;i<=m;i++) { sum+=(qsm(i,n)-qsm(i-1,n)-qsm(i-1,n-1)*n%mod*(m-i+1)%mod)*i+qsm(i,n-1)*n%mod*(m-i)%mod*i%mod; sum%=mod; } cout<<(sum+mod)%mod<<endl; return 0; }