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 mightyvoice at 2009-05-01 15:17:11 on Problem 2190
wa了一次,然后改成
1,如果是10的话不能填在前9位。
2.当填入10但是又不能填在第10位要输出-1.
第二点感觉最阴险了!
然后试了一下就过了,太阴险了,估计很多人就是这里错了。
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{   char a[10];
    while(gets(a))
    {   int i,j,k,sum=0;
        for(i=0;i<10;i++)
        {   if(a[i]!='X' && a[i] != '?') sum+=(10-i)*(a[i]-'0');
            else {   if(a[i] == 'X') sum+=10*(10-i);
                     if(a[i] =='?') k=i;
                 }
        }
        //cout<<sum<<endl;
        bool p=false;

        for(i=0;i<=10;i++)
           { if((sum+i*(10-k))%11 ==0)
                {  p=true;
                   break;
                }
           }
        if(p)
        {   if(i!=10) printf("%d\n",i);
            else {  if(k==9) printf("X\n");
                    else printf("-1\n");
                 }
        }
        else printf("-1\n");
    }
            
            
    system("PAUSE");
    return EXIT_SUCCESS;
}


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