### john_hopes's blog

By john_hopes, history, 23 months ago,

Suppose, I know m1, m2, m3 and P1, P2, P3 of the following equations. Here P1, P2, P3 are prime numbers.

X mod P1 = m1

X mod P2 = m2

X mod P3 = m3

Now, for another prime number P4,

I need to find, X mod P4 = ?

Using Chinese Remainder Theorem I can calculate this if P4 is not a prime and is equal to (P1xP2xP3).

How can I solve this problem for any prime P4?

• +7

By john_hopes, history, 2 years ago,

Is there anyone can help me to solve this problem?

Problem Description:

Alice and Bob take turns playing a game, with Alice going first. They begin with a pile of N stones, each turn removing one less than a prime number of stones. The person who removes the last stone wins. Given N, determine who wins the the game.

Constraints: N>0 and N<=10^9

I already read some solutions. They just pre calculated all the N for which Second Player wins and answer each query.

How can I pre calculate all the N(Second Player wins)?

• 0

By john_hopes, history, 4 years ago,

Could you please give me some Problems Link which requires DP+Priority Queue or DP+Monotonous Queue to solve?

Almost like this problem LINK

Thanks in Advance :)

• +7

By john_hopes, history, 5 years ago,

You'll be given an Array of N elements and Q queries.

Here N and Q is a non-negative integer and maximum value of N and Q is 100000.

There are two types of query.

One is : 1 P V , this means that you have to change P-th element of the array to V.

Another is : 2 L R X , this means that you have to output the number of elements less than or equal to X in L to R range of the array.

How can I solve this problem? I know the solution if there is no update operation. But this problem contains update operation.

Thanks in Advance. :)

• +13

By john_hopes, history, 5 years ago,

How can I find the minimum number of edges need to be added to convert a tree graph to binconnected component such that if we remove an edge from that graph, the graph remain connected? Please give me some idea to do that! Thanks in advance :)

• +11

By john_hopes, history, 5 years ago,

In a bitmask DP problem, there 10 digits. And for every digits I need to store three types of data ( Not used, Used and Using ). One way to solve this is using two bitmask. But for some other reasons It is not possible to use two bitmask in my case. Is there any other memory efficient way to do so? Is there any good resources for learning this?