You are not right because k = 2 => all numerals < 2. Ok? And now I show you this 13 numbers: 111111 111110 111101 111011 110111 101111 111010 110110 110101 101110 101101 101011 101010 sorry for my English
Can anyone please tell me in tabular form what is are the values of answers for the above values. My algorithm is almost right and it is calculating accurately as far as I know but it is always responding No on test # 2. Please help!!! I am stuck and dissappointed.... :(
I got AC with 0.015s,216Kb I had read the problem several time until understand. N is the length of the digit number. It will be something like that a1 a2 a3 ...an for each ai in a1 a2 a3..an, 0 <= ai < K. The output number i used was interger (compiler C++ 2010). (no big number).
hope it can help you. And sorry for my poor English.
Maybe you just thought "00" is not the valid number, but the problem said "0001235 is not a 7-digit number, it is a 4-digit number. ", that means 01, 02...09 are not 2-digit numbers, they are 1-digit numbers, so the answer should be 90.
> pow(10,2)==99 It's really weird if some language's standard library doesn't work in so visible way. User mistake is much more likely. So what is language and "pow" function declaration?
Probably you use any floating numbers pow, like "C++, double pow (double base, double exponent)". In this case I expect pow returns approx. 100 (99.999 for example) and then you convert double to int in wrong way.
I've done with DP in 0.001 sec It's very difficult to explain how you can get this formula. Maybe you'll understand : Just it necessary to know how many new numbers you can get with knowing that numbers having 0 in the end give less than numbers having any another digit in the end. Sorry if I have some mistakes in it.