int lower_solve( LL N) { return 5 * ( log ( N) / log ( 4 ) ) - 0.1 ; }
unordered_map< LL,int > memo;
int solve( LL N) {
if ( N == 0 ) return 0 ;
if ( memo.count ( N) ) return memo[ N] ;
int res = min( 1000ll, N) ;
for ( int mul = 2 ; mul + 1 < res; mul++ ) {
int add = N % mul;
if ( add + mul + 1 + lower_solve( N / mul) >= res) continue ;
int ris = add + mul + 1 + solve( N / mul) ;
res = min( res, ris) ;
}
memo[ N] = res;
return res;
}
aW50IGxvd2VyX3NvbHZlKExMIE4pIHsgcmV0dXJuIDUqKGxvZyhOKS9sb2coNCkpIC0gMC4xOyB9Cgp1bm9yZGVyZWRfbWFwPExMLGludD4gbWVtbzsKaW50IHNvbHZlKExMIE4pIHsKICAgIGlmIChOID09IDApIHJldHVybiAwOwogICAgaWYgKG1lbW8uY291bnQoTikpIHJldHVybiBtZW1vW05dOwogICAgaW50IHJlcyA9IG1pbigxMDAwbGwsIE4pOwogICAgZm9yIChpbnQgbXVsID0gMjsgbXVsICsgMSA8IHJlczsgbXVsKyspIHsKICAgICAgICBpbnQgYWRkID0gTiAlIG11bDsKICAgICAgICBpZiAoYWRkICsgbXVsICsgMSArIGxvd2VyX3NvbHZlKE4gLyBtdWwpID49IHJlcykgY29udGludWU7CiAgICAgICAgaW50IHJpcyA9IGFkZCArIG11bCArIDEgKyBzb2x2ZShOIC8gbXVsKTsKICAgICAgICByZXMgPSBtaW4ocmVzLCByaXMpOwogICAgfQogICAgCiAgICBtZW1vW05dID0gcmVzOwogICAgcmV0dXJuIHJlczsKfQ==
compilation info
prog.cpp:1:17: error: ‘LL’ was not declared in this scope
int lower_solve(LL N) { return 5*(log(N)/log(4)) - 0.1; }
^~
prog.cpp:3:1: error: ‘unordered_map’ does not name a type
unordered_map<LL,int> memo;
^~~~~~~~~~~~~
prog.cpp:4:11: error: ‘LL’ was not declared in this scope
int solve(LL N) {
^~
stdout