07-03 00:01
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- dbms
- External Scheme
- Entity
- BFS
- Class
- Mac
- 셀레니움
- python
- Polymolphism
- X.org
- descriptive statistics
- 리눅스
- 백준
- X윈도우
- preprocessing
- 리눅스 마스터 1급
- Inheritance
- Physical Scheme
- selenium
- Unity
- OOP
- literal
- 리눅스 기초
- Reference Type
- 자바
- Entity Set
- Java
- Operator
- systemd
- Binary Search
Archives
- Today
- Total
Byeol Lo
N1193 - 분수찾기 본문
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int level = (int) Math.ceil((-1 + Math.sqrt(1 + 8 * n)) / 2);
int a = n - (level - 1) * level / 2;
int b = level + 1 - a;
if (level % 2 == 0) {
System.out.println(a + "/" + b);
} else {
System.out.println(b + "/" + a);
}
}
}
'Algorithm > Math' 카테고리의 다른 글
N11653 - 소인수분해 (0) | 2024.06.22 |
---|---|
N2903 - 중앙 이동 알고리즘 (0) | 2024.06.15 |
N13241 - 최소공배수 구하기 (0) | 2024.06.15 |
Comments