문제
In St Petersburg phone numbers are formatted as “XXX–XX–XX”, where the first three digits represent index of the Automated Telephone Exchange (ATE). Each ATE has exactly 10 000 unique phone numbers.
Peter has just bought a new flat and now he wants to install a telephone line. He thinks that a phone number is lucky if the arithmetic expression represented by that phone number is equal to zero. For example, the phone number 102–40–62 is lucky (102 − 40 − 62 = 0), and the number 157–10–47 is not lucky (157 − 10 − 47 = 100 ≠ 0).
Peter knows the index of the ATE that serves his house. To get an idea of his chances to get a lucky number he wants to know how many lucky numbers his ATE has.
입력
The input file contains a single integer number n — the index of Peter’s ATE (100 ≤ n ≤ 999).
출력
Output a single integer number — the number of lucky phone numbers Peter’s ATE has.
풀이
주어지는 수 N에 대해 합이 N인 두 자리수를 뺀 값이 0이 되는 경우가 몇 개인지 구하는 문제다.
때문제 N이 198보다 큰 경우에는 0이 되는 경우가 존재하지 않으며,
198 미만인 경우에는 99 - (N-99) + 1이 성립한다.
소스코드
출처
'PS > Baekjoon Online Judge' 카테고리의 다른 글
[백준 03533] Explicit Formula [Java] (0) | 2023.11.29 |
---|---|
[백준 03512] Flat [Java] (0) | 2023.11.27 |
[백준 03276] ICONS [Java] (1) | 2023.11.24 |
[백준 03059] 등장하지 않는 문자의 합 [Java] (1) | 2023.11.23 |
[백준 03058] 짝수를 찾아라 [Java] (1) | 2023.11.22 |