結果

問題 No.1138 No Bingo!
ユーザー 👑 kmjpkmjp
提出日時 2020-07-26 23:17:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 3,000 ms
コード長 1,125 bytes
コンパイル時間 4,295 ms
コンパイル使用メモリ 199,864 KB
実行使用メモリ 6,564 KB
最終ジャッジ日時 2023-09-11 05:18:21
合計ジャッジ時間 3,952 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 4 ms
4,960 KB
testcase_04 AC 6 ms
6,504 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 5 ms
5,128 KB
testcase_10 AC 5 ms
6,308 KB
testcase_11 AC 6 ms
6,536 KB
testcase_12 AC 3 ms
4,624 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 6 ms
6,564 KB
testcase_15 AC 4 ms
4,612 KB
testcase_16 AC 6 ms
6,344 KB
testcase_17 AC 6 ms
6,280 KB
testcase_18 AC 6 ms
6,176 KB
testcase_19 AC 4 ms
5,268 KB
testcase_20 AC 5 ms
6,100 KB
testcase_21 AC 6 ms
6,172 KB
testcase_22 AC 5 ms
5,872 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 4 ms
5,056 KB
testcase_25 AC 3 ms
4,468 KB
testcase_26 AC 3 ms
4,384 KB
testcase_27 AC 4 ms
5,052 KB
testcase_28 AC 3 ms
4,380 KB
testcase_29 AC 3 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


ll N;
const ll mo=998244353;

ll S[5];
ll A[202020];
ll B[202020];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	
	S[1]=1;
	for(i=1;i<=N;i++) S[1]=S[1]*i%mo;
	A[0]=B[0]=1;
	for(i=2;i<=N;i++) {
		A[i]=(i-1)*(A[i-1]+A[i-2])%mo;
		if(i>=4) {
			if(i%2==0) B[i]=((i-1)*B[i-1]+2*(i-2)*B[i-4])%mo;
			else B[i]=((i-1)*B[i-1]+2*(i-1)*B[i-2])%mo;
		}
	}
	S[2]=S[3]=A[N];
	S[4]=B[N];
	
	ll ret=S[1]-S[2]-S[3]+S[4]+mo+mo;
	cout<<ret%mo<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0