Почему в случае 1 10 ответ 9 если 0 тоже число в котором не идут два подряд ноля? Просто 2 раза получил ВА, поменял на 9 и АС. N ≥ 2. Test "1 10" is incorrect; there is no such test in the test set. You are wrong. In case 1 10 you have exactly nine 1-digit numbers without two or more subsequent zeros. They are: 1,2,3,4,5,6,7,8 and 9. What do you mean? '0' is *also* a 1-digit number without two or more subsequent zeroes, no? Also, yay for necroposting! a valid n digit number can be found from valid n-1 and n-2 digit numbers Edited by author 16.02.2021 13:56 Edited by author 16.02.2021 13:56 and also N=6,K=10 N=7,K=10 N=6,K=2 N=5,K=10 the answer is 87480 N=6,K=10 the answer is 866781 N=7,K=10 the answer is 8588349 N=6,K=2 the answer is 13 my program has been accepted I have solved this problem,but I got WA on test #2.When n=6,k=10 I get answer 866781 and others tests I get right answer.What is the test #2??????????????? N=5,K=10 the answer is 87480 350975 350974 350973 350971 350970 350967 350966 350965 350959 350958 350957 350955 350954 350943 350942 350941 350939 350938 for n = 6 , k = 2 this values are true more than 13 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 Edited by author 19.08.2020 13:21 Edited by author 19.08.2020 13:21 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.... :( 1 10 -> 9 2 10 -> 90 3 10 -> 891 4 10 -> 8829 5 10 -> 87480 6 10 -> 866781 7 10 -> 8588349 8 10 -> 85096170 ... 88 10 -> 4073204239463162109734811048211023806979858806092557057802513502380259034152215057201989 how for k=3 it should be 90 input 3 5 output : 96 input 10 2 output: 89 Edited by author 14.04.2019 17:30 Edited by author 14.04.2019 17:36 Edited by author 19.02.2016 19:17 why is k =10 and n =2 output =90 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. Edited by author 25.04.2014 23:05 thanks an phan. through your post, i have understanded a bit. but why K = 10. when a1 a2 a3....an <10 and lager or equal 0. i thinks result = 99. why 90? i suspect it? Thanks you so muck. From task: > 0001235 is not a 7-digit number, it is a 4-digit number. So first zero isn't allowed. So, 0 < a1 < 10 0 <= a2...an < 10 Result is 9*10 = 90 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. Dear anphan . Your question is jam <3 <3<3 This is my code: import time import sys sys.setrecursionlimit(100000) n = int(input("Enter N (for digits): ")) k = int(input("Enter K: ")) rangeVar = pow(k, n) - pow(k, n-1) starter = pow(k, n) - rangeVar counter = 0 start = time.clock() def calc(i): global starter, rangeVar, counter, n, k temp = str(i)
if i == pow(k, n): return counter else: for j in range(len(temp) - 1): if temp[j] == '0' and temp[j+1] == '0': counter += 1 calc(i+1)
calc(starter) end = time.clock() print(rangeVar - counter) print(end - start) My English is poor, but I read it by a large time and I understood. N=2,K=10 ==>it's a "2 digits 10-base" 10,11,...98,99... in Chinese "2位的十进制数字" if k equal to 30 and n equal to 2 , numbers are 30 , 31 , 32 , 33 , .......,99 is it true? Edited by author 10.10.2012 23:50 Edited by author 10.10.2012 23:50 10 based notation of 10 is 10 but 2 based notation of 10 is 1010 I understand if k equal to 30 and n equal to 2 , numbers are 30 , 31 , 32 , 33 , .......,99 is it true? Edited by author 10.10.2012 23:50 Edited by author 10.10.2012 23:50 I don't understand. How can k equal to 30... In statement there is limit 2 ≤ K ≤ 10; N位数长,K进制,的所有数字中,不包含两个连续0的所有数字的个数。 oh my god!i like your answer! I got 89 for the example: 2 10, not 90, why? Any one know this? 9*10=90; 9 - count of possible first digits (zero not allowed); 10 - count of possible second digits. How did you get 89? it's because of pow-function pow(10,2)==99 U may: if ( result_of_pow % 9 == 0) result_of_pow++; Edited by author 25.02.2016 17:48 > 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. Edited by author 25.02.2016 20:35 I missed placed 2 as k and 10 as n, ar, that's stupid. i solved this by using Optimized backtracking and i don't understand why it needs DP? 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. I have solved it both ways with DP and BackTracking, my question is aren't limits to easy to pass? Edited by author 21.01.2016 20:56 Edited by author 21.01.2016 20:56 неправильно: n=3 k=10 =>891 n=4 k=10 =>8829 ещё тесты: n=16 k=2 =>1597 n=8 k=8 => 13464808 и ещё:использовать лучше самый большой тип First digit of the numbers will start from 1 and end with non-zero digit.and there will not present any successive zero. Edited by author 27.10.2014 14:27 For example, I have n = 3 and k = 2, which means 0 and 1 Then there is 3 possible ways to made a number: 101, 111, 110 How to calculate this moment, when n is more than k????? I think l have solved this problem,but i got WA on test #2. For my solution replacing integer 32-bit with 64-bit integer helped, and all tests passed. There is a 32-bit integer overflow in test #2. help plz,thx! Don't know, but replacing int->int64_t (32-bit integers with 64-bit integers) helped for my solution, there is some integer overflow in test #2. |
|