全部RE
查看原帖
全部RE
591979
ShenRuochen楼主2022/2/5 18:29

洛谷在线IDE和Dev-C++测试样例都AC,测试数据全部RE,已经调了1小时了。 代码

#include <bits/stdc++.h>
using namespace std;
long long res[21][21][21];
long long w(long long x,long long y,long long z)
{
	if(x<=0||y<=0||z<=0)return 1;
	else if(res[x][y][z]!=0)return res[x][y][z];
	else if(x>20||y>20||z>20)res[x][y][z]=w(20,20,20);
	else if(x<y&&y<z)res[x][y][z]=w(x,y,z-1)+w(x,y-1,z-1)-w(x,y-1,z);
	else res[x][y][z]=w(x-1,y,z)+w(x-1,y-1,z)+w(x-1,y,z-1)-w(x-1,y-1,z-1);
	return res[x][y][z];
}
int main()
{
	long long a,b,c;
	while(scanf("%lld%lld%lld",&a,&b,&c)==3)
	{
		memset(res,0,sizeof(res));
		if(a==-1&&b==-1&&c==-1)return 0;
		else 
		{
			
			printf("w(%lld, %lld, %lld) = ",a,b,c);
			if(a>20)a=21;
			if(b>20)b=21;
			if(c>20)c=21;
			printf("%lld\n",w(a,b,c));
		}
	}
	return 0;
}

2022/2/5 18:29
加载中...