백준 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 | #include <iostream> using namespace std; int main() { int index = 0; int n, i, r; cin >> n; for (i = 0; i < n; i += index) { ++index; } r = i - n; if (index % 2 == 1) { cout << r + 1 << " / " << index - r << endl; } else { cout << index - r << " / " << r + 1 << endl; } return 0; } | cs |
'BeakJoon' 카테고리의 다른 글
백준 15596 : 정수 N개의 합 (0) | 2020.08.28 |
---|---|
백준 4673 : 셀프 넘버 (0) | 2020.08.28 |
백준 2775 : 부녀회장이 될테야 (0) | 2020.08.28 |
백준 2292 : 벌집 (0) | 2020.08.28 |
백준 2750 : 수 정렬하기 (0) | 2020.08.28 |
TAGS.