| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- JDBC
- transactional
- Hexagonal
- Adapter
- springboot
- hexagonal architecture
- JPA
- Transaction
- Spring Data JPA
- Spring
- 실무
- Layered Architecture
- simplejpaRepository
Archives
- Today
- Total
Ezcho
[1011] Fly me to the Alpha Centauri(코드) 본문
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static int l;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
StringBuilder sb = new StringBuilder();
for(int j = 0;j<t;j++) {
StringTokenizer st = new StringTokenizer(br.readLine());
int x = Integer.parseInt(st.nextToken());
int y = Integer.parseInt(st.nextToken());
l = y-x;
int cnt = 0;
for(int i=1; i<l ; i++){
if(l<i)
break;
else{
l = l-i;
cnt++;
if(l<i){
break;
}
else{
l = l-i;
cnt++;
}
}
}
if(l==0)
sb.append(cnt).append("\n");
else
sb.append(cnt+1).append("\n");
}
System.out.print(sb);
}
}'Algorithm > BOJ' 카테고리의 다른 글
| [1016] 제곱 ㄴㄴ 수(코드) (0) | 2022.11.13 |
|---|---|
| [17387] 선분 교차 판별 II(코드) (0) | 2022.10.09 |
| [17386] 선분 교차 판별 1(코드) (0) | 2022.10.02 |
| [13270]피보나치킨(코드+풀이) (1) | 2022.09.14 |
| [1316] 그룹 단어 체커(java) (0) | 2022.08.08 |
Comments