Nombres unidígit X78783


Statement
 

pdf   zip

Un nombre natural nn és pot representar en base bb amb una seqüència de dígits (dm,dm1,,d1,d0)(d_m, d_{m-1}, \ldots, d_1, d_0) tal que n=i=0mdibi,amb 0di<b.n = \sum_{i=0}^{m} d_i\cdot b^i, \qquad \mbox{amb~} 0 \leq d_i < b. Per exemple, 15 es pot representar amb (1,1,1,1)(1,1,1,1) en base 2, 109 es pot representar amb (1,2,3,1)(1,2,3,1) en base 4 i 10818 es pot representar amb (18,18,18)(18, 18, 18) en base 24, perquè:

15=𝟏23+𝟏22+𝟏21+𝟏20109=𝟏43+𝟐42+𝟑41+𝟏4010818=𝟏𝟖242+𝟏𝟖241+𝟏𝟖240\begin{eqnarray*} 15 & = & \mathbf{1}\cdot 2^3 + \mathbf{1}\cdot 2^2 + \mathbf{1} \cdot 2^1 + \mathbf{1} \cdot 2^0\\ 109 & = & \mathbf{1}\cdot 4^3 + \mathbf{2}\cdot 4^2 + \mathbf{3} \cdot 4^1 + \mathbf{1} \cdot 4^0\\ 10818 & = & \mathbf{18} \cdot 24^2 + \mathbf{18} \cdot 24^1 + \mathbf{18} \cdot 24^0 \end{eqnarray*}

Diem que un nombre és unidígit en base bb si, quan es representa en aquella base, tots els dígits de la seqüència són iguals. Als exemples anteriors, doncs, el 15 és unidígit en base 2 i el 10818 és unidígit en base 24, però el 109 no és unidígit en base 4.

Es pot observar que tot nombre n3n \geq 3 és unidígit en base n1n-1 amb la representació (1,1)(1,1).

Entrada

L’entrada consisteix en una seqüència de naturals estrictament positius.

Sortida

Per a cada nombre xx de l’entrada cal cercar la base bb més petita (b2b \geq 2) per a la qual xx és unidígit en base bb. Una vegada trobada aquesta base bb, cal escriure tres informacions: el nombre de dígits de la representació de xx en base bb, el valor del dígit dd que es repeteix en la representació, i la base bb trobada.

Public test cases
  • Input

    1
    11
    15
    35
    242
    270
    1023
    10818
    1384309
    

    Output

    1 1 2
    2 1 10
    4 1 2
    2 5 6
    5 2 3
    2 15 17
    10 1 2
    3 18 24
    2 1 1384308
    
  • Information
    Author
    Jordi Cortadella
    Language
    Catalan
    Official solutions
    C++ Python
    User solutions