RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00520

Lun

Unrated 레이팅 미적용
난이도
1s
시간 제한
64MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

1 \(s / 64\) \(MB / 50\) points

Mom Tihana wanted to buy her daughter Leda a plush toy via an online store. During the purchase

process, the system asked for a credit card number to be entered. However, the purchase failed

because Tihana mistakenly wrote one of the digits from that number. Internet research has revealed

that such systems recognize the wrong number based on Luhn's algorithm.
This algorithm confirms the correctness of the number using a control digit which is always the last

digit in the number. Steps to determine the validity of a number are:

Starting from the second digit from the right in the number (tens of the number), double the

value of every second digit to the left. If this product is greater than nine, then the digits of that

product should be summed up.

Calculate the sum of all values obtained in the previous step.

The sum thus obtained should be multiplied by nine and it should be determined the

remainder of division by ten.

If the resulting remainder is equal to the last digit of the number (unit), the number is

considered valid.

E.g. account number 79927398713 is considered valid because the end right digit 3 can be obtained

from the remaining digits in the way described.

Account
number
7
9
9
2
7
3
9
8
7
1
3
Double
every other
7
18
9
4
7
6
9
16
7
2
-
Sum
7
9
(\(1+8\))
9
4
7
6
9
7
(\(6+1\))
7
2
= 67
(Sum after intermediate st\(ep \cdot 9\)) mod 10 = (\(67 \cdot 9\)) mod \(10 = 603\) mod 10 = 3

Write a program that loads the card number as a \(N\) -string that consists only of digits and exactly one

sign "x", and prints the smallest o\(ne-di\)git number which we can replace the sign "x" with so that the

account number is valid.

제약

In the test samples totally worth 25 points, the sign "x" will always be in the last place in the string.

1 \(s / 64\) \(MB / 50\) points

입력 형식

In the first line there is an integer number \(N\) (1 ≤ \(N\) ≤ 100) , the length of string from the task's test.
In the second line there is a string of length \(N\) consisting of just signs “0”, “1”, “2”, “3”, “4”, “5”, “6”, “7” ,

“8”, “9” and exactly one sign "x".

출력 형식

In the only line of the output it should be printed the required o\(ne-di\)git number.

예제 1
입력
11
7992739871x

5
x2464

10
93380x1696
출력
output
output
3

5

1
문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2018/2019 Contest 6

평가 및 의견

Lun

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Lun

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8