mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
1b4d6396e4
2700-2799
52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
#include <iostream>
|
|
#include <algorithm>
|
|
#include <string>
|
|
#include <set>
|
|
#include <map>
|
|
#include <utility>
|
|
#include <queue>
|
|
#include <stack>
|
|
#include <list>
|
|
#include <vector>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <cmath>
|
|
using namespace std;
|
|
int main ()
|
|
{
|
|
string str;
|
|
while ( cin >> str )
|
|
{
|
|
int N = str.size();
|
|
int sum = 0, ask = 0;
|
|
for ( int i = 1; i <= N; ++ i )
|
|
{
|
|
switch ( str[i-1] )
|
|
{
|
|
case 'X':
|
|
sum += (10-i+1) * 10; break;
|
|
case '?':
|
|
ask = 10-i+1; break;
|
|
default :
|
|
sum += (10-i+1) * (str[i-1] - '0'); break;
|
|
}
|
|
}
|
|
int pos = -1;
|
|
for ( int i = 0; i <= 10; ++ i )
|
|
{
|
|
if ( ( sum + ask * i ) % 11 == 0 )
|
|
{
|
|
pos = i;
|
|
break;
|
|
}
|
|
}
|
|
if ( ask != 1 && pos == 10 ) pos = -1;
|
|
if ( pos == 10 )
|
|
cout << 'X' << endl;
|
|
else
|
|
cout << pos << endl;
|
|
}
|
|
return 0;
|
|
}
|