Vector P to store the base k representation of the number
vector < ll > p ; ll x = n ; while ( x ) { p . pb ( x % k ) ; x /= k ; } int idx = 0 ; for ( ll i = 0 ; i < ( ll ) p . size ( ) - 1 ; ++ i ) { if ( p [ i ] >= 2 ) {