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

哪里错了,狂WA不止

Posted by wanglinggui at 2008-05-24 21:28:52 on Problem 2033
#include <iostream>
using namespace std;

const int N = 100000;

char s[N];
int s1[N];
bool f(int a, int b)
{
	return a  * 10 + b < 27;
}
int main()
{
	double a[N];

	int i, j;
	
	while(cin>>s, s[0] != '0' )
	{

		for(i=j=0; s[i]; i++)
		{
			if(s[i] != '0') s1[j++] = s[i] - '0';
			else s1[j - 1] *= 10;
		}
		if ( j == 1)
		{
			puts("1");
			continue;
		}
		a[0] = 1;
		if(s1[0] <10 && f(s1[0], s1[1]) ) a[1] = 2;
		else a[1] = 1;
		for(i=2; i<j; i++)
		{
			a[i] = a[i-1];
			if(s1[i] < 10 && f( s1[i-1], s1[i]) ) a[i] += a[i-2];
		}
		printf("%.0lf\n", a[i-1]);
	}
	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