求助,自己测没问题

P1464 Function

改为 ```cpp #include<bits/stdc++.h> using namespace std; long long nn[89][89][89]; long long w(long long a,long long b,long long c) { if(nn[a][b][c]>0) { return nn[a][b][c]; } if(a<=0||b<=0||c<=0) { return 1; } else { if(a>20||b>20||c>20) { nn[a][b][c]=w(20,20,20); return nn[a][b][c]; } else { if(a<b&&b<c) { nn[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c); return nn[a][b][c]; } else { nn[a][b][c]=w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1); return nn[a][b][c]; } } } return nn[a][b][c]; } int main() { long long a,b,c; while(true) { cin>>a>>b>>c; if(a==-1&&b==-1&&c==-1) { break; } printf("w(%d, %d, %d) = %d",a,b,c,w(a,b,c)); } return 0; } ```
by szlh_XJS @ 2023-05-11 18:13:33


找到了一个错[评测记录](https://www.luogu.com.cn/record/110061934)
by szlh_XJS @ 2023-05-11 18:15:04


```cpp#include<iostream> #include<cstdio> using namespace std; typedef long long ll; ll a,b,c,note[30][30][30] = {0}; ll w(ll i,ll j,ll k){ if(i<=0||j<=0||k<=0) return 1; if(i>20||j>20||k>20) return w(20,20,20); if(i<j&&j<k){ if(note[i][j][k-1] == 0){ note[i][j][k-1] = w(i,j,k-1); } if(note[i][j-1][k-1] == 0){ note[i][j-1][k-1] = w(i,j-1,k-1); } if(note[i][j-1][k] == 0){ note[i][j-1][k] = w(i,j-1,k); } note[i][j][k] = note[i][j][k-1] + note[i][j-1][k-1] - note[i][j-1][k]; //返回 } else{//其他情况 if(note[i-1][j][k] == 0){ note[i-1][j][k] = w(i-1,j,k); } if(note[i-1][j-1][k] == 0){ note[i-1][j-1][k] = w(i-1,j-1,k); } if(note[i-1][j][k-1] == 0){ note[i-1][j][k-1] = w(i-1,j,k-1); } if(note[i-1][j-1][k-1] == 0){ note[i-1][j-1][k-1] = w(i-1,j-1,k-1); } note[i][j][k] = note[i-1][j][k] + note[i-1][j-1][k] + note[i-1][j][k-1] - note[i-1][j-1][k-1]; } return note[i][j][k]; } int main(){ while(1){ cin>>a>>b>>c; if(a==-1&&b==-1&&c==-1) return 0; cout<<"w("<<a<<", "<<b<<", "<<c<<')'<<" = "<<w(a,b,c)<<endl; } }
by cjlchenjunlin2012 @ 2023-05-11 22:01:42


|