洛谷 p1464

记忆化搜索 说白了就是搜索打表

#include 
#include 
#include 
#include 
#include 
using namespace std;
int book[25][25][25];
int w(int a,int b,int c)
{
    if(a<=0||b<=0||c<=0) return 1;
    else if(a>20||b>20||c>20) return w(20,20,20);
    if(!book[a][b][c])
    {
        if(a1)+w(a,b-1,c-1)-w(a,b-1,c);
        else book[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);

    }return book[a][b][c];
}
int main()
{
    long long a,b,c;
    while(cin>>a>>b>>c)
    {
        if(a==-1&&b==-1&&c==-1) break;
        cout<<"w("<", "<", "<") = "<

你可能感兴趣的:(基础,洛谷)