-
Notifications
You must be signed in to change notification settings - Fork 0
/
백준 문제 페이지 찾기.js
44 lines (31 loc) · 1 KB
/
백준 문제 페이지 찾기.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//백준에서 해당 번호로 문제를 검색하고자 할 때 몇 페이지에 있는지
//확인하는 간단한 코드입니다
const { off } = require('process')
const readline = require('readline')
const { fileURLToPath } = require('url')
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
})
const data = []
rl.on('line', (input) => {
data.push(input)
}).on('close', () => {
// // 부루트 포스로 모든 찾을 때까지 것을 돌아가며 탐색
// let num=data.shift()
// let page=1
// let find=1000
// while(1){
// if(num>=find&&num<=(find+99)){
// break
// }
// find+=100
// page++
// }
// console.log(`question number ${num} is located on p.${page}`)
// 탐색보다 보다 간편한 공식을 통해 검색
let num = data.shift()
let page = parseInt(num / 100) - 9
console.log(`question number ${num} is located on p.${page}`)
process.exit()
})