全wa了,各位来帮帮孩子吧
  • 板块P1464 Function
  • 楼主sajdhkja
  • 当前回复2
  • 已保存回复2
  • 发布时间2022/1/29 16:26
  • 上次更新2023/10/28 10:24:34
查看原帖
全wa了,各位来帮帮孩子吧
618195
sajdhkja楼主2022/1/29 16:26
#include<bits/stdc++.h>
#define int long long
using namespace std;const int inf=1e5+10;
#define endl '\n'
int memory[25][25][25];
struct node{
    int a,b,c;
};

// unordered_map<node,int>q;

int w(node root)
{
    
    // if(q.count(root))return q[root];
    if(root.c<=0||root.b<=0||root.a<=0){return 1;}
    if(root.c>20||root.b>20||root.a>20){root.c=20,root.b=20,root.a=20;}
    if(memory[root.a][root.b][root.c])return memory[root.a][root.b][root.c];
    if(root.a<root.b&&root.b<root.c){
        memory[root.a][root.b][root.c]=w({root.a,root.b,root.c-1})+w({root.a,root.b-1,root.c-1})+w({root.a,root.b-1,root.c});
        // q[root]=k;
        return memory[root.a][root.b][root.c];
    }
    else{
        memory[root.a][root.b][root.c]=w({root.a-1,root.b,root.c})+w({root.a-1,root.b-1,root.c})+w({root.a-1,root.b,root.c-1})-w({root.a-1,root.b-1,root.c-1});
        // q[root]=k;
        return memory[root.a][root.b][root.c];
    }
}

signed main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    node root;

    while (cin>>root.a>>root.b>>root.c,!(root.c==-1&&root.b==-1&&root.a==-1))
    {
        node copy=root;
        int ans=w(root);
        printf("w(%lld, %lld, %lld) = %lld\n",copy.a,copy.b,copy.c,ans);
    }

    return 0;
}
2022/1/29 16:26
加载中...