結果

問題 No.1138 No Bingo!
ユーザー kotatsugamekotatsugame
提出日時 2020-07-27 01:36:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 501 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 65,008 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2023-09-11 05:30:45
合計ジャッジ時間 3,574 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 4 ms
4,900 KB
testcase_04 RE -
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 5 ms
5,228 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 3 ms
4,620 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 RE -
testcase_15 AC 4 ms
4,612 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 5 ms
5,196 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 5 ms
5,248 KB
testcase_25 AC 3 ms
4,408 KB
testcase_26 AC 3 ms
4,548 KB
testcase_27 AC 4 ms
4,892 KB
testcase_28 AC 3 ms
4,384 KB
testcase_29 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
const long mod=998244353;
int N;
long FAC,ALL[1<<17],TWO[1<<17];
int main()
{
    cin>>N;
    FAC=1;
    for(int i=1;i<=N;i++)FAC=FAC*i%mod;
    ALL[1]=0;
    ALL[2]=1;
    for(int i=3;i<=N;i++)ALL[i]=(i-1)*(ALL[i-1]+ALL[i-2])%mod;
    TWO[0]=1;
    for(int i=3;i<=N;i++)
    {
        if(i%2==1)TWO[i]=((i-1)*TWO[i-1]+2*(i-1)*TWO[i-2])%mod;
        else TWO[i]=((i-1)*TWO[i-1]+2*(i-2)*TWO[i-4])%mod;
    }
    cout<<((FAC-2*ALL[N]+TWO[N])%mod+mod)%mod<<endl;
}
0