| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
runtime ERROR求解啊#include<stdio.h>
#include<string.h>
int w[22][22][22];
int fun(int , int , int );
void main()
{
int a,b,c;
memset(w,0,sizeof(w));
while((scanf("%d%d%d",&a,&b,&c))!=EOF)
{ if(a==-1 && b==-1 && c==-1)
{
break;
}
printf("w(%d, %d, %d) = %d\n",a,b,c,fun(a, b, c));
}
}
int fun(int a, int b, int c)
{
if(a<=0 || b<=0 || c<=0)
{
return w[0][0][0] = 1;
}
if(w[a][b][c])
{
return w[a][b][c];
}
else if(a>20 || b>20 || c>20)
{
return w[20][20][20] = fun(20, 20, 20);
}
else if(a<b && b<c)
{
return w[a][b][c]=fun(a, b, c-1) + fun(a, b-1, c-1) - fun(a, b-1, c);
}
else
{
return w[a][b][c]= fun(a-1, b, c) + fun(a-1, b-1, c) + fun(a-1, b, c-1) - fun(a-1, b-1, c-1);
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator