RE 求助

P1464 Function

RID: [146495061](https://www.luogu.com.cn/record/146495061)
by xk2013 @ 2024-02-07 21:33:41


本贴不玄关,但玄……玄[「YCOI」出题组](https://www.luogu.com.cn/team/60565)名额!
by xk2013 @ 2024-02-07 21:34:58


@[xk2013](/user/998662) 你最好不用三维数组,#1的a就是>200000
by sybnb @ 2024-02-08 22:04:46


只对于你的代码
by sybnb @ 2024-02-08 22:07:36


@[xk2013](/user/998662) 这是我的代码 ```cpp #include<iostream> #include<cstdio> using namespace std; long long ans[35][35][35]; long long a, b, c; long long f(long long a, long long b, long long c){ if(a <= 0||b <= 0||c <= 0) { return 1; } else if(a > 20||b > 20||c > 20) { return ans[20][20][20] ? ans[20][20][20] : ans[20][20][20] = f(20,20,20); } else if(a < b&b < c) { return ans[a][b][c] ? ans[a][b][c] : ans[a][b][c] = f(a,b,c-1) + f(a,b-1,c-1) - f(a,b-1,c); } else { return ans[a][b][c] ? ans[a][b][c] : ans[a][b][c] = f(a-1,b,c) + f(a-1,b-1,c) + f(a-1,b,c-1) - f(a-1,b-1,c-1); } } int main(){ scanf("%lld%lld%lld", &a, &b, &c); while(a != -1||b != -1||c != -1) { printf("w(%lld, %lld, %lld) = %lld\n", a, b, c, f(a,b,c)); scanf("%lld%lld%lld", &a, &b, &c); } return 0; } ```
by sybnb @ 2024-02-08 22:20:55


@[xk2013](/user/998662) 记忆化搜索是先处理边界,在判断有没有算过,不是先判断,在处理边界。
by Abelxxyy @ 2024-02-25 09:24:26


|