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 |
Tags
- Linux
- PostgreSQL
- 추상클래스
- 자바
- Javascript
- IntelliJ
- DBMS
- 트랜잭션
- mysql
- 명령어
- SQL
- group by
- rsync
- 리눅스
- mssql
- java
- 티스토리챌린지
- analytics4
- docker
- oracle
- top
- MongoDB
- git
- JPA
- 차이점
- 오블완
- 호이스팅
- MariaDB
- spring
- 인터페이스
Archives
- Today
- Total
hanker
백준 JAVA - FlymetotheAlphaCentauri 본문
반응형
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
for(int i = 0 ; i < N ; i++){
int x = sc.nextInt();
int y = sc.nextInt();
int dist = y - x;
int max = (int)Math.sqrt(dist);
if(max == Math.sqrt(dist)){
System.out.println(max * 2 - 1);
} else if (dist <= max * max + max){
System.out.println(max * 2);
} else{
System.out.println(max * 2 + 1);
}
}
}
}
참고
[백준] 1011번 : Fly me to the Alpha Centauri - JAVA [자바]
https://www.acmicpc.net/problem/1011 1011번: Fly me to the Alpha Centauri 우현이는 어린 시절, 지구 외의 다른 행성에서도 인류들이 살아갈 수 있는 미래가 오리라 믿었다. 그리고 그가 지구라는 세상에 발을..
st-lab.tistory.com
반응형
'Study > ALGORITHM' 카테고리의 다른 글
백준(2581) JAVA - 소수 (0) | 2021.05.09 |
---|---|
백준(1978) JAVA - 소수 찾기 (0) | 2021.05.08 |
백준(10757) JAVA - 큰 수 A + B (0) | 2021.04.30 |
백준(2775) JAVA - 부녀회장이 될테야 (0) | 2021.04.29 |
백준(10250) JAVA - ACM 호텔 (0) | 2021.04.23 |