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

Re:其实这题不用定义数组的//恩,提醒了我,受教

Posted by darkcaller at 2011-02-21 13:17:55 on Problem 2033
In Reply To:其实这题不用定义数组的 Posted by:plumstar at 2008-05-24 14:04:19
#include<iostream>
#include<string>

using namespace std;

int main()
{
	int i,len;
	long d,d1,d2;
	string s;
	while(cin>>s,s.at(0)!='0')
	{
		len=s.size();
		d1=s.at(len-1)=='0'?0:1;
		d2=1;
		d=1;
		for(i=len-2;i>=0;--i)
		{
			if(s.at(i)>'2'||(s.at(i)=='2'&&s.at(i+1)>'7'))
				d=d1;
			else d=d1+d2;
			d2=d1;
			d1=d;
			if(s.at(i)=='0')
				d1=0;
			if(s.at(i+1)=='0')
				d2=0;
		}
		cout<<d<<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