Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 프로그래머스
- SWEA
- BOJ
- 건강
- oracle
- 자바
- 시뮬레이션
- 러닝일지
- 문제해결
- math
- db
- COS PRO
- 문자열
- dfs
- 백준
- 투포인터
- DP
- greedy
- 알고리즘
- Java
- 운동기록
- 코딩테스트
- MySQL
- 코테
- 이분탐색
- priorityqueue
- SQL
- 문제풀이
- BFS
- binary search
Archives
- Today
- Total
슈콩
[BOJ] 백준 1011 Fly me to the Alpha Centauri 본문
[문제]
https://www.acmicpc.net/problem/1011
[소스 코드]
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int n = Integer.parseInt(br.readLine());
while(n-->0) {
st = new StringTokenizer(br.readLine());
int x = Integer.parseInt(st.nextToken());
int y = Integer.parseInt(st.nextToken());
int dis = y - x;
int max = (int)Math.sqrt(dis);
if(max==Math.sqrt(dis))
System.out.println(max*2-1);
else if(dis<=max*max+max)
System.out.println(max*2);
else
System.out.println(max*2+1);
}
}
}'Algorithms > Baekjoon' 카테고리의 다른 글
| [BOJ] 백준 10250 ACM 호텔 (0) | 2025.09.07 |
|---|---|
| [BOJ] 백준 1019 책 페이지 (0) | 2025.09.06 |
| [BOJ] 백준 11051 이항계수2 (0) | 2025.09.05 |
| [BOJ] 백준 6064 카잉 달력 (0) | 2025.09.05 |
| [BOJ] 백준 11653 소인수분해 (0) | 2025.09.05 |