cswork / OAOpen practice workspace

DTCCOA #1

Find Reciprocal

EasyJudge-ready

Topics (AI-labelled)Bits & MathHashing

Given an integer N, find the decimal expansion of 1/N. Output the non-repeating prefix of the decimal plus one copy of the repeating cycle, then, after a space, the repeating cycle once more. A terminating decimal is treated as having the repeating cycle 0.

Input

The input is an integer N (2 ≤ N ≤ 10^5).

Output

Output 0., the non-repeating prefix, one copy of the repeating cycle, a space, and the second copy of the repeating cycle. If the decimal terminates, the repeating cycle is 0.

Example 1

Input:

2

Output:

0.50 0

Example 2

Input:

3

Output:

0.3 3

Example notes

Record the position where each remainder first appears during long division; the cycle starts where a remainder repeats. When the remainder is 0, the remaining decimal digits repeat 0 forever.

Editorial

Loading solution…