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

2033 为什么老是WA啊? 哪位大哥帮忙看一下咯。。。。。

Posted by yuhailin at 2009-06-07 22:10:24
#include<iostream>
using namespace std;
char  str[5001];
int   len[5001]; 
int dp(char ch[]){
  int temp;
  len[0]=1; 
  temp=(ch[0]-'0')*10+(ch[1]-'0');
  
  if(temp>0&&temp<=26&&ch[1]!=0)
        len[1]=2;    
  else  len[1]=1;    
  for(int i=2;i<strlen(ch);i++)
  {
   temp=(ch[i-1]-'0')*10+(ch[i]-'0');       
   if(ch[i]=='0')len[i]=len[i-2];
   else
     if(temp>0&&temp<=26&&ch[i-1]!='0')   
       len[i]=len[i-1]+len[i-2];         
     else len[i]=len[i-1];
  } 
  return len[strlen(ch)-1]; 
                        }
int main(){
    while(1)
    {
     cin>>str;
     if(str[0]=='0') break; 
     cout<<dp(str)<<endl;       
            
    } 
    system("pause");
    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