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.
# Enter your code here. Read input from STDIN. Print output to STDOUT#count of n digit numbersfac=[i*9*10**(i-1)foriinrange(1,18)]#aggregate of the first 1 to n digit numberfac1=[fac[0]]foriinrange(1,len(fac)):fac1.append(fac[i]+fac1[i-1])#print(fac, fac1) deffind_digit(n):ifn<9:return(n)forjinrange(len(fac1)):ifn==fac1[j]:return(9)ifn<fac1[j]:breakn,r=(n-fac1[j-1])//(j+1),(n-fac1[j-1])%(j+1)#if remainder r == 0 , then this is the last digit of the n-1 numbern=n-1ifr==0elsen#if 190 is question it is first digit of 100(first 3 digit number) i.e 1 return(int(str(10**j+n)[jifr==0elser-1]))fora0inrange(int(input())):n=map(int,input().split())prod=1foriinn:prod*=find_digit(i)print(prod)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Project Euler #40: Champernowne's constant
You are viewing a single comment's thread. Return to all comments →
100% python