📄 1331 function run fun.cpp
字号:
/*
1331 Function Run Fun
Time Limit : 1000 ms Memory Limit : 32768 K Output Limit : 256 K
GUN C++
*/
#include <iostream>
using namespace std;
const int Max=21;
int w[Max][Max][Max]={0};
bool v[Max][Max][Max]={false};
int solve(int a,int b,int c)
{
int temp;
if(a<=0 || b<=0 || c<=0)
return 1;
if(a>20 || b>20 || c>20)
return solve(20,20,20);
if(v[a][b][c])
return w[a][b][c];
else
{
if(a<b && b<c)
{
temp=solve(a, b, c-1) + solve(a, b-1, c-1) - solve(a, b-1, c);
v[a][b][c]=true;
w[a][b][c]=temp;
}
else
{
temp=solve(a-1, b, c) + solve(a-1, b-1, c) + solve(a-1, b, c-1) - solve(a-1, b-1, c-1);
v[a][b][c]=true;
w[a][b][c]=temp;
}
return temp;
}
}
int main()
{
int a,b,c,i,j,k;
while(cin>>a>>b>>c && (a!=-1 || b!=-1 || c!=-1) )
{
cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<solve(a,b,c)<<endl;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -