MC_dream_tsr @ 2024-08-06 15:30:51
全TLE能理解,麻烦大家找下那唯一一个re错哪了,新学递归(没学太好可能递归就错了),不求AC,过来练习一下,谢谢
# include<bits/stdc++.h>
using namespace std;
int w(long long a, long long b, long long 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 - 1, c - 1);
}
int main(){
int kkk = 10000 + 5;
long long a[kkk] = {0}, b[kkk] = {0}, c[kkk] = {0}, d[kkk] = {0}, n = 0;
for(int i = 1; ; i++){
cin >> a[i] >> b[i] >> c[i];
if(a[i] == -1 && b[i] == -1 && c[i] == -1) break;
n++;
}
for(int i = 1; i <= n; i++)
cout << "w(" << a[i] << ", " << b[i] << ", " << c[i] << ", " << ") = "
<< w(a[i], b[i], c[i]) << endl;
return 0;
}
by HEzzz @ 2024-08-06 15:33:17
数组没开够,而且递归写错了
by HEzzz @ 2024-08-06 15:34:14
还有多处细节错误
by HEzzz @ 2024-08-06 15:36:52
@tsr20110331
by MC_dream_tsr @ 2024-08-06 15:39:52
@HEzzz a....请问递归哪错了,QAQ
by HEzzz @ 2024-08-06 15:43:08
@tsr20110331
首先第二个
by HEzzz @ 2024-08-06 15:43:45
还有就是
by MC_dream_tsr @ 2024-08-06 15:52:05
@HEzzz ok,收到,谢谢,等学完搜索再来AC这道题,已经没事了