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 |
此帖作废,,,,发晕的错误In Reply To:这道题目有什么陷阱啊,,我怎么老WA?帮忙看看好吗? Posted by:deep_you at 2005-10-26 19:29:57 > #include <stdio.h> > #include <memory.h> > char map[50][50]; > long value[60][60]; > long zg(long num1,long num2) > { > while(num1%num2!=0) > { > long k; > k=num1%num2; > num1=num2; > num2=k; > } > return num2; > } > > int main() > { > int n,m,i,j; > long sum,nn; > char str[1000]; > scanf("%d %d",&n,&m); > getchar(); > for(i=0;i<n;i++) > { > int p=0; > j=0; > gets(str); > while(str[p]) > { > if(str[p]=='*'||str[p]=='.') > { > map[i][j]=str[p]; > j++; > } > p++; > } > > } > memset(value,0,sizeof(int)*60*60); > value[0][0]=1; > for(i=0;i<n;i++) > { > for(j=0;j<=i;j++) > { > if(value[i][j]==0)continue; > if(i!=n&&map[i][j]=='.')value[i+2][j+1]+=value[i][j]*4; > else > { > value[i+1][j]+=value[i][j]; > value[i+1][j+1]+=value[i][j]; > } > } > } > sum=0; > for(j=0;j<=n;j++) > { > sum+=value[n][j]; > } > if(value[n][m]!=0) > { > nn=zg(sum,value[n][m]); > printf("%ld/%ld\n",value[n][m]/nn,sum/nn); > } > else printf("0/1\n"); > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator