| ||||||||||
| 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 | |||||||||
注意10只能在最后一位注意10只能在最后一位 10在其他位数时输出为-1 测试数据时会测试到 太恶心了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#include <stdio.h>
int main()
{
char str[10],a[10];
int i,s=0,t;
gets(str);
for(i=9;i>=0;i--)
a[i]=str[9-i];
for(i=0;i<10;i++)
{
if(a[i]=='X')
s+=10;
if(a[i]>='0'&&a[i]<='9')
s+=(i+1)*(a[i]-48);
if(a[i]=='?')
t=i;
}
for(i=0;i<=10;i++)
{
if(!((s+(t+1)*i)%11))
{
s+=(t+1)*i;
break;
}
}
if(i==10&&t==0)
printf("X");
else if(i>=0&&i<=9)
printf("%d",i);
else
printf("-1");
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator