結果
| 問題 |
No.1552 Simple Dice Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-18 21:36:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 442 ms / 2,500 ms |
| コード長 | 494 bytes |
| コンパイル時間 | 622 ms |
| コンパイル使用メモリ | 70,216 KB |
| 実行使用メモリ | 8,772 KB |
| 最終ジャッジ日時 | 2024-06-22 20:00:36 |
| 合計ジャッジ時間 | 6,472 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | main()
| ^~~~
ソースコード
#include<iostream>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
long N;
int M;
mint L[5<<17],R[5<<17];
main()
{
cin>>N>>M;
L[0]=0;
mint ans=0,pre=0;
for(int i=1;i<=M;i++)
{
L[i]=mint(i).pow(N)*N*(i+1)/2;
mint tmp=L[i];
L[i]-=pre;
pre=tmp;
ans+=i*L[i];
}
R[M+1]=0;
pre=0;
for(int i=M;i>=1;i--)
{
int j=M-i+1;
R[i]=mint(j).pow(N)*N*(M-mint(j-1)/2);
mint tmp=R[i];
R[i]-=pre;
pre=tmp;
ans-=i*R[i];
}
cout<<ans.val()<<endl;
}