8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 5739c5a + 19d57a2 commit 0514bfcCopy full SHA for 0514bfc
0x12/solutions/1193
18.4 KB
0x12/solutions/1193.cpp
@@ -1,11 +1,29 @@
1
-// Authored by : BaaaaaaaaaaarkingDog
+// Authored by : SciEm
2
// Co-authored by : -
3
-// http://boj.kr/****************
+// http://boj.kr/4786afbccbb148098938f248823abd35
4
#include <bits/stdc++.h>
5
using namespace std;
6
7
-int main(void){
+int main() {
8
ios::sync_with_stdio(0);
9
cin.tie(0);
10
-
11
-}
+
+ int x;
12
+ cin >> x;
13
14
+ // x에서 1 2 3 ...을 빼다보면 찾는 수가 i 번째 군의 x 번째 수가 된다.
15
+ int i = 1;
16
+ while (x > i) {
17
+ x -= i;
18
+ i++;
19
+ }
20
21
+ int nume = x;
22
+ int deno = i + 1 - x;
23
+ if (i % 2) swap(nume, deno); // 홀수 번째 군의 순서가 문제와 반대이므로 뒤집는다.
24
+ cout << nume << '/' << deno;
25
+}
26
+/*
27
+수열을 (1/1) (1/2 2/1) (1/3 2/2 3/1) ... 과 같이 묶으면 i번째 군의 개수는
28
+i개 이고 분자와 분모의 합이 i + 1로 일정함을 알 수 있다.
29
+*/
0 commit comments