結果

問題 No.1138 No Bingo!
ユーザー ytftytft
提出日時 2021-05-07 17:59:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 3,000 ms
コード長 645 bytes
コンパイル時間 11,044 ms
コンパイル使用メモリ 374,600 KB
実行使用メモリ 6,212 KB
最終ジャッジ日時 2023-10-13 09:12:51
合計ジャッジ時間 12,228 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 4 ms
4,556 KB
testcase_04 AC 6 ms
6,188 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 4 ms
4,900 KB
testcase_10 AC 5 ms
5,592 KB
testcase_11 AC 6 ms
6,212 KB
testcase_12 AC 3 ms
4,352 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 6 ms
5,928 KB
testcase_15 AC 3 ms
4,368 KB
testcase_16 AC 5 ms
5,608 KB
testcase_17 AC 6 ms
5,708 KB
testcase_18 AC 5 ms
5,656 KB
testcase_19 AC 4 ms
4,916 KB
testcase_20 AC 5 ms
5,804 KB
testcase_21 AC 5 ms
5,720 KB
testcase_22 AC 5 ms
5,352 KB
testcase_23 AC 2 ms
4,352 KB
testcase_24 AC 5 ms
4,864 KB
testcase_25 AC 3 ms
4,352 KB
testcase_26 AC 3 ms
4,352 KB
testcase_27 AC 4 ms
4,636 KB
testcase_28 AC 3 ms
4,352 KB
testcase_29 AC 3 ms
4,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
namespace mp=boost::multiprecision;

int main(){
    int N;
    cin>>N;
    long long MOD=998244353;
    vector<long long> A(N+1),B(N+1);
    long long ans=1;
    A[0]=1;
    for(int i=4;i<=N;i++){
        if(i%2){
            A[i]=((i-1)*A[i-1]+2*(i-1)*A[i-2])%MOD;
        }else{
            A[i]=((i-1)*A[i-1]+2*(i-2)*A[i-4])%MOD;
        }
    }
    B[0]=1;
    for(int i=1;i<=N;i++){
        B[i]=(i*B[i-1]+(i%2?-1:1))%MOD;
        ans=(ans*i)%MOD;
    }
    ans=(ans-2*B[N]+A[N])%MOD;
    while(ans<0){
        ans+=MOD;
    }
    cout<<ans<<endl;
}
0