Back
Close

Infinite division

Statement
The purpose of this problem is to compute all the decimals of the division between 2 integers. [[a]] / [[b]] the result will be given in a specific format {{x.y(z)}} where {{x}} is the integer part of the result, {{y}} is the finite decimal part of the result decimal, and {{z}} the infinite part (cycling) of the the division. <<Example>> 11 / 24 = 0.45833333333...... the integer part {{x}} = 0 the finite part {{y}} = 458 the cyclic part {{z}} = 3 the result will be printed : 0.458(3) <<Notes:>> the finite part may not exist, for example 1/3 -> 0.(3) the cyclic part is always printed even if it's 0, for example 4/2 -> 2.(0)

Input description
2 integer [[a]] and [[b]]

Output description
the result of the division written in the format {{x.y(z)}}

Constraints
0<[[a]]<1000 0<[[b]]<1000

Game modes
Fastest

Test cases
Example Test
Input
11 24
Output
0.458(3)

Validator 1 Validator
Input
13 24
Output
0.541(6)

Finite part only Test
Input
1 2
Output
0.5(0)

Validator 2 Validator
Input
6 48
Output
0.125(0)

Integer only Test
Input
10 5
Output
2.(0)

Validator 3 Validator
Input
30 10
Output
3.(0)

Test 4 Test
Input
533 482
Output
1.1(058091286307053941908713692946)

Validator 4 Validator
Input
537 382
Output
1.4(05759162303664921465968586387434554973821989528795811518324607329842931937172774869109947643979)

Solution language

Solution

Stub generator input
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants