1027E - Inverse Coloring - CodeForces Solution


combinatorics dp math *2100

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
const int N=505;
int dis[N],dis2[N],mid=998244353; 
signed main(){
	int n=read(),k2=read();
	int sum=0;
	for(int i=1;i<=n;++i){
		dis[0]=1;
		for(int j=1;j<=n;++j){
			dis[j]=0;
			for(int k=1;k<=min(i,j);++k){
				dis[j]=dis[j]+dis[j-k];
				dis[j]%=mid; 
			}
		}
		dis2[i]=(dis[n]%mid-sum%mid+mid)%mid;
		sum=dis[n]%mid;
	}
	int ans=0;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if(i*j<k2){
				ans=ans+dis2[i]*dis2[j]%mid;
				ans%=mid;
			}
		}
	}
	ans*=2;
	ans%=mid;
	printf("%lld\n",ans%mid);
	return 0;
}


Comments

Submit
0 Comments
More Questions

230A - Dragons
200B - Drinks
13A - Numbers
129A - Cookies
1367B - Even Array
136A - Presents
1450A - Avoid Trygub
327A - Flipping Game
411A - Password Check
1520C - Not Adjacent Matrix
1538B - Friends and Candies
580A - Kefa and First Steps
1038B - Non-Coprime Partition
43A - Football
50A - Domino piling
479A - Expression
1480A - Yet Another String Game
1216C - White Sheet
1648A - Weird Sum
427A - Police Recruits
535A - Tavas and Nafas
581A - Vasya the Hipster
1537B - Bad Boy
1406B - Maximum Product
507B - Amr and Pins
379A - New Year Candles
1154A - Restoring Three Numbers
750A - New Year and Hurry
705A - Hulk
492B - Vanya and Lanterns