PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000057. Phân số ở vị trí N (A Rational Sequence Take 3)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Phân số ở vị trí N (A Rational Sequence Take 3)

A Rational Sequence (Take 3)

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

In the infinite binary tree rooted at 1/1, the left child of p/q is p/(p+q) and the right child is (p+q)/q. Its breadth-first, left-to-right traversal defines F(1)=1/1, F(2)=1/2, F(3)=2/1, etc. Given a one-based index n, output the exact reduced fraction F(n).

Input

A single integer n.

Output

The reduced fraction p/q.

Subtasks

  • Subtask 1 (20 points): 1≤n≤10231\le n\le 1023.
  • Subtask 2 (30 points): 1≤n≤1061\le n\le 10^6.
  • Subtask 3 (50 points): 1≤n≤231−11\le n\le 2^{31}-1.

Examples

Input

11

Output

5/2

Explanation

Index 11 has binary representation 1011. Following L, R, R from the root gives 5/2.