| ||||||||||
| 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 | |||||||||
Help. What is the error?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator