답안 #161858

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
161858 2019-11-04T20:09:30 Z boolodifjenula Lun (COCI19_lun) Python 3
50 / 50
28 ms 3428 KB
N=int(input())
S=input()
T=S[N-1]
z=0
if T=="x":
    for i in range(N-2,-1,-1):
        if N%2==0 and i%2==0 or N%2==1 and i%2==1:
            z+=(2*int(S[i]))%10+(2*int(S[i]))//10
        else:
            z+=int(S[i])
    print(z*9%10)
else:
    m=0
    T=int(T)
    x=0
    for i in range(N-2,-1,-1):
        if S[i]!="x" and (N%2==0 and i%2==0 or N%2==1 and i%2==1):
            z+=(2*int(S[i]))%10+(2*int(S[i]))//10
        elif S[i]!="x":
            z+=int(S[i])
        if S[i]=="x":
            m=i
    while 1:
        if N%2==0 and m%2==0 or N%2==1 and m%2==1:
            if (z+(2*x)%10+(2*x)//10)*9%10==T:
                print(x)
                break
        else:
            if (z+x)*9%10==T:
                print(x)
                break
        x+=1
                
            
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 3428 KB Output is correct
2 Correct 25 ms 3428 KB Output is correct
3 Correct 25 ms 3304 KB Output is correct
4 Correct 25 ms 3324 KB Output is correct
5 Correct 28 ms 3332 KB Output is correct
6 Correct 27 ms 3324 KB Output is correct
7 Correct 26 ms 3428 KB Output is correct
8 Correct 25 ms 3328 KB Output is correct
9 Correct 25 ms 3428 KB Output is correct
10 Correct 25 ms 3428 KB Output is correct