답안 #704454

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
704454 2023-03-02T06:48:16 Z delrey Lun (COCI19_lun) C++14
40 / 50
0 ms 212 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    string s;
    cin>>n>>s;
    int x = 0;
    while(s[x] != 'x')
        x++;
    int sum = 0;
    for(int i = n - 2; i >= 0; i--)
    {
        if(s[i] == 'x')
            continue;
        int a = s[i] - '0';
        if((n - 2 - i) % 2 == 0)
        {
            a *= 2;
            if(a > 9)
                a = a / 10 + a % 10;
        }
        sum += a;
        //cout<<a<<" ";
    }
    //cout<<endl<<sum<<" ";
    sum *= 9;
    sum %= 10;
    //cout<<sum<<" "<<endl;
    if(x == n - 1)
    {
        cout<<sum<<endl;
        return 0;
    }
    for(int i = 0; i < 10; i++)
    {
        int sum2 = sum, a = i;
        if((n - 2 - x) % 2 == 0)
        {
            a *= 2;
            if(a > 9)
                a = a / 10 + a % 10;
        }
        sum2 = (sum2 + ((a * 9) % 10)) % 10;
        if(sum2 == s[n - 1] - '0')
        {
            cout<<a<<endl;
            return 0;
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 0 ms 212 KB Output isn't correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Correct 0 ms 212 KB Output is correct