家人们,不是很理解哪里错了

P1464 Function

zhang2026 @ 2022-05-13 19:50:22


#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int w(int a,int b,int c)
{
    if(a<=0||b<=0||c<=0) return 1;
    if(a>20||b>20||c>20) return w(20,20,20);
    if(a<b||b<c) return w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
    else return 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()
{
    while(1)
    {
        cin>>a>>b>>c;
        if(a==-1&&b==-1&&c==-1) break;
        cout<<"w("<<a<<","<<b<<","<<c<<") = "<<w(a,b,c)<<endl;
    }
    return 0;
}

by dingshengyang @ 2022-05-13 19:55:07

记忆化!!!


by dingshengyang @ 2022-05-13 19:55:39

对于这种 SB 错误,我不想回答


by hwh_qwq @ 2022-05-13 19:55:41

这样写会超时,需要用记忆化搜索。


by 大眼仔Happy @ 2022-05-13 19:58:58

我很好奇,然后点开了你的练习。


by Galex @ 2022-05-13 19:59:32

4黑/xia


by irris @ 2022-05-13 20:07:42

举办 zhang2026 喵,举办 zhang2026 谢谢喵


by Node_Edge @ 2022-05-13 20:07:50

@大眼仔Happy P1587 抄了第二篇题解


by 大眼仔Happy @ 2022-05-13 20:09:00

@Node_Edge 是否可以举报?


by Node_Edge @ 2022-05-13 20:09:36

@大眼仔Happy 凑齐三个一个月以内的,大家都找一找


by Node_Edge @ 2022-05-13 20:11:00

P1173 抄第四篇的


| 下一页