https://www.acmicpc.net/problem/3507
3507번: Automated Telephone Exchange
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
www.acmicpc.net
문제
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.
예제 입력 1
196
예제 출력 1
3
예제 입력 2
239
예제 출력 2
0
코드
const N = Number(require('fs').readFileSync('/dev/stdin').toString());
let count = 0;
for(let i = 1; i < 100; i++){
for(let j = 1; j < 100; j++){
if(N - i - j === 0) count++;
}
}
console.log(count);
'알고리즘 > 백준' 카테고리의 다른 글
[백준] 15995: 잉여역수 구하기 / Node.js (JavaScript) (0) | 2023.04.05 |
---|---|
[백준] 3602: iChess / Node.js (JavaScript) (0) | 2023.04.04 |
[백준] 3276: ICONS / Node.js (JavaScript) (0) | 2023.04.02 |
[백준] 2501: 약수 구하기 / Node.js (JavaScript) (0) | 2023.04.01 |
[백준] 15633: Fan Death / Node.js (JavaScript) (0) | 2023.04.01 |
댓글