Блог пользователя aditya123garg

Автор aditya123garg, история, 5 лет назад, По-английски

Hey Guys, there was a question in Round 2 of the HackWithInfy Contest which I feel is quite nice and I wasn't able to think of any possible solution to it. So the question goes like that:-

We have defined a function f(x) = sum of all the digits of x. Now,

0 <= i <= N

0 <= j <= N

We have to count how many pairs are there which satisfy the condition that f(i) + f(j) is a prime.

Constraints:- 0 <= N <= 10^50

Example:-

1) N = 2

pairs = 2

2) N = 3

pairs = 4

Can anyone suggest some possible method to solve this question??

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by aditya123garg (previous revision, new revision, compare).

»
5 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Read this blog you might get some help Digit Dp

  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Hey, Thnks for replying. I knew about digit dp but couldn't think of the possible recurrence. Can you help with that?