cswork / OA打开练习工作台

DTCCOA #1

Find Reciprocal

简单可在线判题

考点(AI 标注)位运算哈希计数

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.

输入格式

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

输出格式

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.

样例 1

输入:

2

输出:

0.50 0

样例 2

输入:

3

输出:

0.3 3

样例说明

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.