Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

呼...ac了,原来'0'处理错了

Posted by ArXoR at 2004-12-29 10:51:00 on Problem 2033
In Reply To:疯了,怎么老是wa?递推算法有什么地方错了吗? Posted by:ArXoR at 2004-12-28 23:44:28
> #include "stdio.h"
> #include "string.h"
> 
> int main(){
>     unsigned long a,b,c;
>     long i;
>     char temp[50000],t;
> 	for (scanf("%s",temp);temp[0]!='0';scanf("%s",temp)){
> 	    for (i=strlen(temp)-2,b=c=1;i>=0;i--){
> 		if (temp[i]=='0')
> 		    continue;
> 		if (temp[i+1]=='0' || 10*temp[i]+temp[i+1]-11*'0'>26)
> 		    {a=b;c=b;b=a;}
>   		else {a=b+c;c=b;b=a;}
>        	    }
> 	    printf("%d\n",b);
> 	}
> 	return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator