MLE!

P2089 烤鸡

递归出口不行,栈空间溢出
by egg_rat @ 2023-12-10 14:23:13


如果n-z>3的时候r=9dfs就永远不会退出了
by egg_rat @ 2023-12-10 14:24:18


@[egg_rat](/user/672534) 谢谢啦
by yhdxg @ 2023-12-10 14:39:00


@[egg_rat](/user/672534) 但为什么c++编译器输出还很正常啊?
by yhdxg @ 2023-12-10 14:40:12


@[egg_rat](/user/672534) 加了 ```cpp if(n-z>3*(10-r)){ return 0; } ``` 过了
by yhdxg @ 2023-12-10 14:44:40


@[yhdxg](/user/1050431) 可能是数据强度太弱
by egg_rat @ 2023-12-10 15:40:25


@[yhdxg](/user/1050431) 这是我的代码 ``` #include <bits/stdc++.h> #define int long long using namespace std; int k[50][15],cnt; void baoli(int x){ for(int a=1;a<=3;a++){ for(int b=1;b<=3;b++){ for(int c=1;c<=3;c++){ for(int d=1;d<=3;d++){ for(int e=1;e<=3;e++){ for(int f=1;f<=3;f++){ for(int g=1;g<=3;g++){ for(int h=1;h<=3;h++){ for(int i=1;i<=3;i++){ for(int j=1;j<=3;j++){ if(a+b+c+d+e+f+g+h+i+j==x){ cnt++; } } } } } } } } } } } } void shuchu(int x){ for(int a=1;a<=3;a++){ for(int b=1;b<=3;b++){ for(int c=1;c<=3;c++){ for(int d=1;d<=3;d++){ for(int e=1;e<=3;e++){ for(int f=1;f<=3;f++){ for(int g=1;g<=3;g++){ for(int h=1;h<=3;h++){ for(int i=1;i<=3;i++){ for(int j=1;j<=3;j++){ if(a+b+c+d+e+f+g+h+i+j==x){ cout<<a<<" "<<b<<" "<<c<<" "; cout<<d<<" "; cout<<e<<" "<<f<<" "<<g<<" "; cout<<h<<" "<<i<<" "<<j<<endl; } } } } } } } } } } } } signed main(){ int n;cin>>n; baoli(n); cout<<cnt<<endl; shuchu(n); return 0; } ```
by HUDSI1256 @ 2024-02-20 17:58:48


@[HUDSI1256](/user/1189304) 我这是正解,艺术美学(你)
by yhdxg @ 2024-02-21 11:27:30


@[yhdxg](/user/1050431) 这不就是暴力枚举题单里的啊,肯定要《暴力枚举》啊
by HUDSI1256 @ 2024-02-21 17:35:42


|