Submission #5888199


Source Code Expand

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
long long fact[110000];
long long finv[110000];
long long inv[110000];
long long dp[3100][6100];
long long C(int a,int b){
	if(b<0||a<b)return 0;
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
int main(){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<110000;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<110000;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
	int a,b;scanf("%d%d",&a,&b);
	dp[0][0]=1;
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			if(!dp[i][j])continue;
			dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
			dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod;
			dp[i+1][j+2]=(dp[i+1][j+2]+dp[i][j])%mod;
		}
	}
	long long ret=0;
	for(int i=0;i<b;i++)ret=(ret+dp[a][i])%mod;
	for(int i=1;i<=a;i++){
		long long ks=C(a,i);
		for(int j=1;j*2<=a;j++){
			if(i+1>b||i*2-j*2+1<=b)continue;
		//	printf("%d %d: %lld\n",i,j,C(i-j*2,b-i-1));
			ret=(ret+C(i-j*2,b-i-1)*ks)%mod;
		}
		if(i*2>b&&b%2==1){
			ret=(ret+ks)%mod;
		}
	}
	printf("%lld\n",ret);
}

Submission Info

Submission Time
Task F - Banned X
User tozangezan
Language C++14 (GCC 5.4.1)
Score 800
Code Size 1625 Byte
Status AC
Exec Time 97 ms
Memory 144512 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:43:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  int a,b;scanf("%d%d",&a,&b);
                             ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 800 / 800
Status
AC × 5
AC × 25
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt, s4.txt, s5.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, s1.txt, s2.txt, s3.txt, s4.txt, s5.txt
Case Name Status Exec Time Memory
01.txt AC 97 ms 144512 KB
02.txt AC 97 ms 144512 KB
03.txt AC 61 ms 109696 KB
04.txt AC 75 ms 128128 KB
05.txt AC 78 ms 136320 KB
06.txt AC 78 ms 136320 KB
07.txt AC 60 ms 128128 KB
08.txt AC 90 ms 140416 KB
09.txt AC 38 ms 144512 KB
10.txt AC 48 ms 109696 KB
11.txt AC 4 ms 3072 KB
12.txt AC 4 ms 3072 KB
13.txt AC 4 ms 3072 KB
14.txt AC 4 ms 3072 KB
15.txt AC 4 ms 3072 KB
16.txt AC 34 ms 144512 KB
17.txt AC 96 ms 144512 KB
18.txt AC 92 ms 140416 KB
19.txt AC 35 ms 144512 KB
20.txt AC 13 ms 44160 KB
s1.txt AC 4 ms 3072 KB
s2.txt AC 4 ms 3072 KB
s3.txt AC 5 ms 3072 KB
s4.txt AC 4 ms 3072 KB
s5.txt AC 8 ms 17536 KB