๋ฐ์ํ
๋์ ํ์ด
package Baekjoon;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Find_Fraction {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(bf.readLine());
String answer = "";
int startNum = 1;
int EndIndex = 1;
while (true) {
EndIndex += startNum++;
if (EndIndex > N) {
startNum--; // ์์ ๋ฒํธ
EndIndex--; // ๋ง์ง๋ง index
break;
}
}
if (startNum % 2 == 0) { // ์ง์ ์ผ๋, 1๋ถํฐ ์ฆ๊ฐ
answer += (startNum - (EndIndex - N)) + "/" + (1 + (EndIndex - N));
} else { // ํ์ ์ผ๋, startNum๋ถํฐ 1์ฉ ๊ฐ์
answer += (1 + (EndIndex - N)) + "/" + (startNum - (EndIndex - N));
}
System.out.println(answer);
}
}
๋ฐ์ํ