Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
Страница 5 |
A simple dp solution is there... | kitesho | 1009. K-ичные числа | 16 фев 2021 13:54 | 1 |
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 |
i dont understand what does the question want? | Navin | 1009. K-ичные числа | 24 сен 2018 12:56 | 1 |
why is k =10 and n =2 output =90 |
for n = 10, k = 2, ans = 89. How?? | iOli | 1009. K-ичные числа | 10 фев 2018 08:18 | 1 |
|
When its n=4 and k=10 its STACK OVERFLOW!!!! HELP !!! | Kevin Narang | 1009. K-ичные числа | 7 ноя 2017 20:18 | 1 |
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) |
mathmatical problem, just use program output answer | clyde | 1009. K-ичные числа | 28 окт 2017 11:38 | 1 |
|
AAaaaaa(????)1009 | TruEror | 1009. K-ичные числа | 16 янв 2017 04:28 | 1 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program { static void Main(string[] args) { int k; int n; do { do{ n = int.Parse(Console.ReadLine()); } while (!(n >= 2)); do { k = int.Parse(Console.ReadLine()); } while (!(k >= 2 && k <= 10)); } while (!(n + k <= 18)); int start = (int)Math.Pow(10, n - 1); int end = 0; int check = start; int BigCount = 0; for (int i = n - 1; i >= 0; i--) end += (k - 1) * (int)Math.Pow(10, i); int h = end - start + 1; int o = 0; for (int l = 0; l < n; l++) { o += h % 10 * (int)Math.Pow(k, l); h = h / 10; } for (int i = 0; i < o; i++) { int count = 0; double p = check; for (int j = 0; j < n / 2; j++) { if ((p % 10 + p / 10 % 10) > 0) count++; p = p / 100; } if (count != 0) BigCount++; check++; count = 0; p = check; int r = 0; int m = 0; for (int l = 0; l < n; l++) { if (p % 10 == k) { count++; m += (10 - k) * (int)Math.Pow(10, l); r = 10 - k; } p += r; p = (int)p / 10; } check += m; } Console.Write(BigCount); } } Норм решение? Edited by author 16.01.2017 04:29 Edited by author 16.01.2017 04:30 |
Why is this problem DP? | Grandmaster | 1009. K-ичные числа | 3 апр 2016 01:18 | 3 |
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? |
solved | Elpsycongroo | 1009. K-ичные числа | 28 янв 2016 07:43 | 3 |
solved Elpsycongroo 13 янв 2016 16:05 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 и ещё:использовать лучше самый большой тип |
I got 89 for the example, not 90, why? | David Yin [ECUPL] | 1009. K-ичные числа | 19 июн 2016 14:02 | 5 |
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. |
wa#2 What is wrong? i am absolutely sure that my solution is right! | Elpsycongroo | 1009. K-ичные числа | 17 ноя 2018 15:14 | 2 |
Edited by author 19.02.2016 19:17 |
characteristics of numbres | anwar_sust | 1009. K-ичные числа | 29 июн 2015 15:19 | 1 |
First digit of the numbers will start from 1 and end with non-zero digit.and there will not present any successive zero. |
c | durgesh pandey | 1009. K-ичные числа | 27 окт 2014 14:26 | 1 |
c durgesh pandey 27 окт 2014 14:26 Edited by author 27.10.2014 14:27 |
WHAT IF n > k ???? | Me | 1009. K-ичные числа | 17 сен 2014 01:52 | 1 |
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????? |
Страница 4 |
To Who do not know the meaning of N and K | an phan | 1009. K-ичные числа | 23 янв 2018 12:30 | 5 |
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 |
WA 1 | Komand_0 | 1009. K-ичные числа | 11 янв 2014 17:46 | 1 |
WA 1 Komand_0 11 янв 2014 17:46 var n,k,tc:integer; a:array [1..20] of integer; procedure gen(x:integer); var i:integer; begin if x = n+1 then inc(tc) else begin if x=1 then for i:=1 to k-1 do begin a[x]:=i; gen(x+1); end else for i:=0 to k-1 do begin a[x]:=i; if (a[x-1]=0) then begin if (i=0) then begin inc(x); dec(x); end; end else gen(x+1); end; end; end; begin readln(n); readln(k); gen(1); writeln(tc); end. What is it! |
Give me example plz | Dias_97 | 1009. K-ичные числа | 20 июн 2019 17:37 | 4 |
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 |
No subject | Dias_97 | 1009. K-ичные числа | 4 янв 2014 15:28 | 1 |
|
Brute force doesn't work here | Marius Zilenas | 1009. K-ичные числа | 15 окт 2013 10:31 | 1 |
Brute force (полный перебор) method gives Time Limit Exceeded. In Java it takes 6 seconds to for parameters N=8, K=10. So the clever method (which uses recurrent calls) is the way to go. |
Is this looks like correct? | PVD | 1009. K-ичные числа | 27 сен 2013 01:36 | 1 |
i have tested it, and it look like working, can you say me is this look like correct, or can you advise me how to fix it?) #include <iostream> using namespace std; int main() { unsigned __int64 n, b, i, r, sum = 0; cin>>n>>b; for (i = 2; i <= n - 1; i++) { r = (n - 1) / i + (n - 1) % i; sum += r * pow(double(b - 1), double(n - i)); } cout<<unsigned __int64(pow(double(b), double(n)) - pow(double(b), double(n - 1)) - sum)<<endl; //system("pause"); } |
Почему не правильно? | Kirill_M | 1009. K-ичные числа | 27 сен 2013 01:46 | 2 |
#include <iostream> #include <string> #include <stdio.h> #include <cmath> using namespace std; int n,k,col=0; int main() {
cin>>n>>k; int bo=0; int z,z1; z=pow(10.0,(n-1)); z1=pow(10.0,n); for(int i=z;i<z1;++i) { for (int v = i; v; v /= 10) { if (((v%10)>=k) || (((v%10)==0) && ((v%100)==0))) {bo=1; v=0;}; } if (!bo) ++col; bo=0; } cout<<col; return 0; } Насколько я понимаю, основание может быть отличным от 10, то есть с основанием, 2, 3, 4, 5, 6, 7, 8, 9. Из-за этого и запись разная, например число 31(осн. 10) = 11111(осн. 2) = 51(осн. 6) = 24(осн.8) = 1F(осн. 16). Вот такие пироги. |