dv.jakhar_'s blog

By dv.jakhar_, history, 3 years ago, In English

Hello codeforces community!

Problem:

Given a lowerlimit and upperlimit (Values on coupon).

A coupon containing the sumofdigits= S will win the lottery. Find S in such a way that max no of people win the lottery.

In short return the count of sum (S) that is repeating max no of times. And the ways to choose that count.

Ex: LL:1 UP:5

array:[1,2,3,4,5]

Sumof digits: [1,2,3,4,5]

Count:1

No of ways to choose that count :5 (max count =1 for 5 )

Ex: LL:1 UP: 10

Array [1,2,3,4,5,6,7,8,9,10]

Sumofdigits: [1,2,3,4,5,6,7,8,9,1]

Count: 2 (sum=1 is repeating 2 times)

No of ways to choose :1

Constraints: 1<=lowerlimit<upperlimit<=10^18

My solution[C++]

Now I want to memoize this rec solution but can't find a way to do it(as currently the func's return type is void). Can someone pls help :) Thanks!

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

»
3 years ago, # |
  Vote: I like it +9 Vote: I do not like it

Didn't get what's going on in your code. Here is my solution for the problem: https://pastebin.com/Uh5CXjc5 May be it will help. :D

  • »
    »
    3 years ago, # ^ |
      Vote: I like it +2 Vote: I do not like it

    Wow, we can go sumwise too...Got this...Thanks a ton, bro! Actually in my solution I was only taking the upper limit for simplicity.

»
4 months ago, # |
  Vote: I like it 0 Vote: I do not like it
My Code