답안 #224942

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224942 2020-04-19T06:38:57 Z VEGAnn Lun (COCI19_lun) C++14
50 / 50
6 ms 512 KB
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
using namespace std;
int n, vl[10] = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9}, loc;
string s;

bool ok(){
    int sm = 0;
    for (int i = 1; i < n; i++)
        if (i & 1){
            sm += vl[s[i] - '0'];
        } else {
            sm += s[i] - '0';
        }
    return ((sm * 9) % 10) == (s[0] - '0');
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> n >> s;

    reverse(all(s));

    loc = s.find('x');

    for (int dg = 0; dg < 10; dg++) {
        s[loc] = char(dg + '0');
        if (ok()){
            cout << dg;
            return 0;
        }
    }

    return -1;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct