| ||||||||||
| 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 | |||||||||
2033 为什么老是WA啊? 哪位大哥帮忙看一下咯。。。。。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator