# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314123 | phathnv | Lun (COCI19_lun) | C++11 | 1 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define taskname "LUN"
using namespace std;
typedef long long ll;
typedef pair <int, int> ii;
int n;
string s;
void readInput(){
cin >> n >> s;
}
bool valid(){
int sum = 0;
for(int i = 0; i < n - 1; i++){
int tmp = s[i] - '0';
if ((i + n - 1) & 1)
tmp <<= 1;
sum += tmp / 10 + tmp % 10;
}
return (sum * 9 % 10 == s[n - 1] - '0');
}
void solve(){
int p = s.find('x');
for(char ch = '0'; ch <= '9'; ch++){
s[p] = ch;
if (valid()){
cout << ch;
return;
}
}
assert(0);
}
int main(){
if (fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
readInput();
solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |