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 |
总是超时,难道真的超时了,大神帮看下#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator