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

诡异的现象,求大牛解释

Posted by shipengbo2006 at 2013-01-28 13:59:13 on Problem 2033
C++编译器下:以下代码提交AC,但是将数组dp改为dp1或pRes等其他变量名后都WA。
#include<cstdio>
#include<cstring>
const int SIZE=5000;
char pStr[SIZE];
int dp[SIZE];
int main()
{
    while(scanf("%s",pStr)!=EOF)
    {
        if(pStr[0]=='0')
        break;
		getchar();
		memset(dp,0,sizeof(dp));
        dp[0]=1;
        dp[1]=1;
		int i;
        for(i=1;pStr[i]!='\0';i++)
        {
            if(pStr[i]=='0')
            {
                dp[i+1]=dp[i-1];
                continue;
            }
            if(pStr[i-1]=='0')
            {
                dp[i+1]=dp[i];
                continue;
            }
            int t=(pStr[i-1]-'0')*10+pStr[i]-'0';
            if(t<=26)
            {
                dp[i+1]=dp[i]+dp[i-1];
            }else
            {
                dp[i+1]=dp[i];
            }
        }
        printf("%d\n",dp[i]);
    }
    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