By aditya123garg, history, 3 years ago,

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

By aditya123garg, history, 4 years ago,

Hey Guys!! I have been trying to understand the Editorial's solution from quite a while now but couldn't get it properly. Can anyone please throw some light on how to proceed it.

What I have understood till now.

At every position, we will assume every possible character to be there in the string c whenever there is asterisk present and after that, we are also maintaining what is the length of the prefix of string t and s which matches with the suffix of string c[0, i]. Now, how to move beyond this?

Can someone provide some similar questions to this one which they have encountered while practicing.

• 0

By aditya123garg, history, 4 years ago,

Hey Guys, My solution to the third problem of yesterday's round(Educational Round 63) fails on test case 20 according to Codeforces compiler but I am getting the correct answer on my own compiler and even on dry running it by myself.

Test case on which it is failing :

2 1 10000000000 20000000000 10000000000

Plzz Guys see to it what's happening here !!

• +12

By aditya123garg, history, 4 years ago,

Hey Guys!! Can anyone give some insights on how to approach this problem from Yesterday's contest?

• +3

By aditya123garg, history, 4 years ago,