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

Help. What is the error?

Posted by ghostshop at 2006-05-01 12:08:04 on Problem 2033
#include<stdio.h>
#include<string.h>
#define M 50000
char s[M];
unsigned alone[M],pre[M];
unsigned
com(int t)
{
	int i;
	alone[0]=1;
	pre[0]=0;
	for(i=1;i<t;i++)
	{
		if(s[i-1]<='2'&&s[i]<='6'&&'0'!=s[i-1])
			pre[i]=alone[i-1];
		else
			pre[i]=0;
		if('0'!=s[i])
			alone[i]=alone[i-1]+pre[i-1];
		else
			alone[i]=0;
	}
	return alone[t-1]+pre[t-1];
}

int
main()
{
	int t;
	while(1)
	{
		scanf("%s",s);
		if('0'==s[0])
			break;
		t=strlen(s);
		printf("%u\n",com(t));
	}
}

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