20分求调
  • 板块P1464 Function
  • 楼主louie2011
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/7/25 19:49
  • 上次更新2024/7/25 20:39:04
查看原帖
20分求调
941801
louie2011楼主2024/7/25 19:49

rt

#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;
int f[25][25][25];
int dfs(int x,int y,int z)
{
	if(x<=0 || y<=0 || z<=0)
	{
		return 1;
	}
	if(x>20 || y>20 || z>20)
	{
		return dfs(20,20,20);
	}
	if(f[x][y][z])
	{
		return f[x][y][z];
	}
	if(x<y && y<z)
	{
		f[x][y][z]=dfs(x,y,z-1)+dfs(x,y-1,z-1)-dfs(x,y-1,z);
	}
	else
	{
		f[x][y][z]=dfs(x-1,y,z)+dfs(x-1,y-1,z)+dfs(x-1,y,z-1)-dfs(x-1,y-1,z-1);
	}
	return f[x][y][z];
}
int a,b,c;
signed main()
{
	while(1)
	{
		cin>>a>>b>>c;
		if(a==-1 && b==-1 && c==-1)
		{
			break;
		}
		cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<dfs(max((long long)0,min((long long)20,a)),max((long long)0,min((long long)20,b)),max((long long)0,min((long long)20,c)))<<endl;;
	}
	return 0;
}
2024/7/25 19:49
加载中...