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

总是超时,难道真的超时了,大神帮看下

Posted by 508618087 at 2012-06-30 23:42:59 on Problem 2033
#include <iostream>
#include <cstring>

using namespace std;

void find(char str[] ,int &s)
{
	if(strlen(str) == 0 || strlen(str) == 1)
	{
		s++;
		return;
	}

	if(str[0] >='3' && str[0] <='6')
		find(str+1,s);
	else
	{
			if(str[1] >'6' || str[1] == '0')
				find(str+2,s);
			else
			{
				find(str+1,s);

				if((str[2]!='0' && str[2] < '7'))
					find(str+2,s);
			}
	}
}
int main()
{
	char str[100000];
	int s =0;

	while(cin>>str,strcmp(str,"0")!=0)
	{
		s =0;
		find(str,s);
		cout<<s<<endl;
	}

	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