gimmickbutreal
[백준/자바] 1193번 해설 - Java 본문
https://www.acmicpc.net/problem/1193
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
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
public static void main(String args[] ) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
int N = Integer.parseInt(str);
int val = 0;
int AP = 0; // 등차수열
while(N > AP){
val++;
AP = val * (val+1) / 2;
}
if(val % 2 == 0){
int top = val - (AP - N);
int btm = 1 + (AP - N);
System.out.println(top+"/"+btm);
}
else{
int top = 1+(AP-N);
int btm = val - (AP-N);
System.out.println(top+"/"+btm);
}
}
}
|
cs |
'Algorithm > Java' 카테고리의 다른 글
[백준/자바] 2775번 해설 - Java (0) | 2022.03.03 |
---|---|
[백준/자바] 2869번 해설 - Java (0) | 2022.03.01 |
[백준/자바] 2292번 해설 - Java (0) | 2022.02.27 |
[백준/자바] 1316번 해설 - Java (0) | 2022.02.24 |
[백준/자바] 2941번 해설 - Java (0) | 2022.02.23 |