

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int input = Integer.parseInt(br.readLine()); // 입력 값
int col = 0; // 칸의 수
int countNum = 1; // 몇 번째 숫자
int numerator = 0; // 분자
int denominator = 0; // 분모
while(col < input) {
col += countNum;
countNum++;
}
if((countNum-1)%2 == 0) {
denominator = 1 + (col - input);
numerator = (countNum-1) - (col-input);
}else {
denominator = (countNum-1) - (col-input);
numerator = 1 + (col - input);
}
System.out.println(numerator+"/"+denominator);
}
}
규칙이 이해가 잘 안 갔다
'Algorithm > Baekjoon' 카테고리의 다른 글
[백준_JAVA] 14215 세 막대 (0) | 2024.02.01 |
---|---|
[백준_JAVA] 9506 약수들의 합 (0) | 2024.01.27 |
[백준_JAVA] 2566 최댓값 (0) | 2024.01.27 |
[백준_JAVA] 10798 세로읽기 (0) | 2024.01.27 |
[백준_JAVA] 15894 수학은 체육과목 입니다 (0) | 2024.01.21 |