liuyiyang0510 @ 2023-12-11 19:04:15
为什么3,7过不了呀
#include <stdio.h>
#include <stdlib.h>
int fun[100][100][100];
int is[100][100][100];
long long int w(long long int a,long long int b,long long int c)
{
if(a<=0||b<=0||c<=0) a=0,b=0,c=0;
if(is[a][b][c])
return fun[a][b][c];
is[a][b][c]=1;
if(a<=0||b<=0||c<=0) return fun[a][b][c]=1;
else if(a>20||b>20||c>20)
return fun[20][20][20]=w(20,20,20);
else if(a<b&&b<c)
return fun[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
else
return fun[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);
}
int main(int argc, char *argv[]) {
long long int a,b,c,m;
while(1){
scanf("%lld %lld %lld",&a,&b,&c);
if(a==-1&&b==-1&&c==-1) break;
printf("w(%lld, %lld, %lld) = ",a,b,c);
if(a>20||b>20||c>20)
m=w(20,20,20);
else m=w(a,b,c);
printf("%lld\n",m);
}
return 0;
}
by Doppler @ 2023-12-12 16:25:42
读题:“注意:例如 w(30,−1,0) 又满足条件1又满足条件2,请按照最上面的条件来算,答案为 1。”
你把#3的(21,-21,20)代到你自己的代码显然不正确
by ditffit @ 2023-12-16 20:19:27
有用