paramvi's blog

By paramvi, history, 15 months ago, In English,

Hi, so this problem was asked in one of the job hiring contest which is over now. So the problem is as follows:

Cool numbers are defined as numbers having digits only 2 and 5. So example of cool digits are 2, 5, 22, 25, 225, while 12, 23, 221 are not cool numbers because all their digits are not from {2, 5}. Let f(k) be defined as the function having value as a cool number greater than or equal to k. For a given pair of { L, R }, I need to evaluate ( f(L)+f(L+1)+....+f(R) ). Constraints of L, R {1<=L<=R<=10^9}

How can I solve the above problem. Any hint or approach is appreciated.

Read more »

  • Vote: I like it  
  • -5
  • Vote: I do not like it  

By paramvi, 3 years ago, In English,

We need to find all numbers between i,j which have 'D' as it's lowest common divisor(LCD). By LCD 'D' of n, I mean there don't exist any number 1<d<D, which divides n.

Constraints : 1<=i<=j<=2*10^9; 1<=D<=2*10^9;

If the constraints hadn't been that much large, it can be trivially solved using sieve of Eratosthenes.

Solution to this problem is appreciated.

Example : lets i,j,D have values 4,16,5 respectively.

So the answer will be following set of numbers: 5. Here 10,15 are not in the answer because 10 is divisible by 5 as well as 2, which is less than 5. Same for 15. Hope it clarify the doubts.

Read more »


By paramvi, 4 years ago, In English,

Hello guys. I need help in cracking a problem. I was trying to do this problem but my answer is coming out to be incorrect. Can you guys please help me in solving this problem.

My Solution.

Let's say number of tiles required at the end of the i-1'th iteration is tile_n. We will store how much area is left in the each of the "tile_n" tiles.

Now for i'th tile in the input, I will go through each of the "tile_n" tiles (stored) and will check if area of the any one of the "tile_n" tiles is greater than i'th tile.

if yes

Let's say it is the j'th tile.

I will check whether or not area of the j'th tile is a multiple of i'th tile. (this is so because we want to cut the proper tile from the j'th tile)


I will add another tile, tiles_n=tiles_n+1

and repeat.

Clearly my solution is lagging somewhere. Can please someone correct my algo. or explain me what to do in this problem.

Read more »