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

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

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
  • Проголосовать: не нравится

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

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

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

Read this blog you might get some help Digit Dp