We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I interpreted the restriction of n < 10^100000 as we would definitely have an
input containing at least 10 ^19 characters which would extrapolate 64 bit
integers.
In these circumstances, this solution that passes all the tests would fail:
intsuperDigitInt(uint64_tn){if(n<10)returnn;uint64_tv=0;while(n){v+=n%10;n/=10;}returnsuperDigitInt(v);}intsuperDigit(stringn,intk){autouncharify=[&k](uint64_tacc,constcharc){returnacc+int(c-'0');};// This won't work for n > 10^19uint64_tprod=accumulate(n.begin(),n.end(),0ULL,uncharify)*k;returnsuperDigitInt(prod);}
A solution that would work for n > 10^19 would require perorm operations with bignum:
Recursive Digit Sum
You are viewing a single comment's thread. Return to all comments →
I interpreted the restriction of n < 10^100000 as we would definitely have an input containing at least 10 ^19 characters which would extrapolate 64 bit integers.
In these circumstances, this solution that passes all the tests would fail:
A solution that would work for n > 10^19 would require perorm operations with bignum: