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 |
Re:其实这题不用定义数组的//恩,提醒了我,受教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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator