늒네 기록

[BOJ-JS] 27646번 - Judicious cuts (Easy) 본문

알골 공부 기록/BOJ

[BOJ-JS] 27646번 - Judicious cuts (Easy)

jaeha lee 2024. 4. 11. 21:57

27646번: Judicious cuts (Easy) (acmicpc.net)

 

27646번: Judicious cuts (Easy)

In the first sample, there is just one line, and that always divides plane into 2 regions. In the second sample, two intersecting lines divide plane into four quadrants. The solution shown for the third case is not optimal, and hence it would not be accept

www.acmicpc.net

선을 최대 1000개 그어서 평면을 n개의 영역으로 나누려고 한다면, y = mx + b 꼴의 직선을 어떻게 그을지 출력하는 문제. 문제 설명에서 예시로 들어주는 케이스들은 죄다 직선들이 서로 만나지만, 잘 생각해보면 서로 평행한 i개의 직선은 평면을 i+1개의 영역으로 나눈다!

[a,...b]=(0+require('fs').readFileSync(0)).split`
`
b.map(i=>{if(i){s='';s+=i-1;for(j=1;j<i;j++)s+='\n1 '+j;console.log(s)}})
반응형
Comments