๋ฐ์ํ
import java.util.Scanner;
// 1193 ๋ถ์์ฐพ๊ธฐ
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int x = in.nextInt();
in.close();
int cnt = 0;
int sum = 0;
int a = 0;
int b = 0;
while (x > sum) {
cnt++;
sum += cnt;
}
// ์ง์์ผ ๊ฒฝ์ฐ
if (cnt % 2 == 0) {
a = cnt - (sum - x);
b = cnt + ((sum - cnt) - x) + 1;
}
else {
a = cnt + ((sum - cnt) - x) +1;
b = cnt - (sum - x);
}
System.out.print(a + "/" + b);
}
}
๋ฐ์ํ
'๐ธ Algorithm > ๐ธ ๋ฐฑ์ค BaekJoon' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค][java][2292][๋ฒ์ง] (0) | 2024.03.15 |
---|---|
[๋ฐฑ์ค][java][2903][์ค์ ์ด๋ ์๊ณ ๋ฆฌ์ฆ] (0) | 2024.03.14 |
[๋ฐฑ์ค][java][2720][์ธํ์ ์ฌ์ฅ ๋ํ] (0) | 2024.03.14 |
[๋ฐฑ์ค][java][11005][์ง๋ฒ ๋ณํ 2] (0) | 2024.03.13 |
[๋ฐฑ์ค][java][2745][์ง๋ฒ ๋ณํ] (3) | 2024.03.12 |