为何爆零
  • 板块P1464 Function
  • 楼主Binah_OVO
  • 当前回复4
  • 已保存回复4
  • 发布时间2025/7/30 19:43
  • 上次更新2025/7/31 10:23:05
查看原帖
为何爆零
1485425
Binah_OVO楼主2025/7/30 19:43

加了记忆化分还比不加的低了😡👍

#include <bits/stdc++.h>
using namespace std;
int DP[500][500][500];
int w(int a,int b,int c)
{
	if(DP[a][b][c]!=0)
		return DP[a][b][c];
	if(a<=0||b<=0||c<=0)
		return 1;
	else if(a>20||b>20||c>20)
		return DP[a][b][c]=w(20,20,20);
	else if(a<b&&b<c)
		return DP[a][b][c]=w(a-1,b,c)+w(a,b,c-1)-w(a,b-1,c);
	else
		return DP[a][b][c]=w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1); 
} 
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<w(a,b,c)<<endl;
	return 0;
}
2025/7/30 19:43
加载中...