-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1193.cpp
53 lines (43 loc) · 803 Bytes
/
1193.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
using namespace std;
int boj_1193() {
long tcase; cin >> tcase;
long num = 0, sum = 0;;
long denominator = 0, numerator = 0;
//denominator(ºÐÀÚ), numerator(ºÐ¸ð)
for (int i = 1; i < tcase;i++) {
sum += i;
if (sum + (i + 1) >= tcase) {
num = i+2;
sum++;
break;
}
}
if (num % 2 == 0) {
denominator = num - 1;
numerator = num - denominator;
}
else {
numerator = num - 1;
denominator = num - numerator;
}
while (1) {
if (sum == tcase) {
break;
}
if (num % 2 == 0) {
denominator--;
numerator++;
if (denominator == 1) break;
}
else {
denominator++;
numerator--;
if (numerator == 1) break;
}
sum++;
}
if (tcase == 1) cout << "1/1" << endl;
else cout << denominator << "/" << numerator << endl;
return 0;
}