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

这个题为啥wa,帮忙看看,谢谢

Posted by ACM_Hohai at 2008-11-23 10:02:29 on Problem 1047
#include<iostream>
using namespace std;
char s[100];
bool cylenum(int len)
{
    int i,hlen=(len>>1),even;
    even=len%2;
    for(i=0;i<hlen;i++)
    {
        if(s[i]+s[hlen+i+even]-'0'=='9')continue;
        else break;
    }
    if(len%2==0&&i==hlen) return true;
    if(len%2&&i==hlen&&s[hlen]=='9') return true;
    else return false;
}

bool allzero(int len)
{
    int i;
    for(i=0;i<len;i++)
    {
        if(s[i]!='0')return false;
    }
    return true;
}
int main()
{
    freopen("in.txt","r",stdin);
    while(scanf("%s",s)!=EOF)
    {
        int len=strlen(s);
        if(strcmp(s,"1")==0||allzero(len))
        {
            printf("%s is cyclic\n",s);
            continue;
        }
        if(cylenum(len))printf("%s is cyclic\n",s);
        else printf("%s is not cyclic\n",s);
    }
    return 1;
}

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