You are in a reality show, and the show is way too real that they threw into an island. Only two kinds of animals are in the island, the tigers and the deer. Though unfortunate but the truth is that, each day exactly two animals meet each other. So, the outcomes are one of the following
If in some day you are sure that you will not be killed, you leave the island immediately and thus win the reality show. And you can assume that two animals in each day are chosen uniformly at random from the set of living creatures in the island (including you).
Now you want to find the expected probability of you winning the game. Since in outcome (d), you can make your own decision, you want to maximize the probability. 继续阅读【概率期望】Island of Survival
Sometimes some mathematical results are hard to believe. One of the common problems is the birthday paradox. Suppose you are in a party where there are 23 people including you. What is the probability that at least two people in the party have same birthday? Surprisingly the result is more than 0.5. Now here you have to do the opposite. You have given the number of days in a year. Remember that you can be in a different planet, for example, in Mars, a year is 669 days long. You have to find the minimum number of people you have to invite in a party such that the probability of at least two people in the party have same birthday is at least 0.5. 继续阅读【概率】Birthday Paradox
As Harry Potter series is over, Harry has no job. Since he wants to make quick money, (he wants everything quick!) so he decided to rob banks. He wants to make a calculated risk, and grab as much money as possible. But his friends – Hermione and Ron have decided upon a tolerable probability P of getting caught. They feel that he is safe enough if the banks he robs together give a probability less than P. 继续阅读【概率DP】Just another Robbery
A lattice point (x, y) in the first quadrant (x and y are integers greater than or equal to 0), other than the origin, is visible from the origin if the line from (0, 0) to (x, y) does not pass through any other lattice point. For example, the point (4, 2) is not visible since the line from the origin passes through (2, 1). The figure below shows the points (x, y) with 0 ≤ x, y ≤ 5 with lines from the origin to the visible points.
Write a program which, given a value for the size, N, computes the number of visible points (x, y) with 0 ≤ x, y ≤ N. 继续阅读【欧拉函数】Visible Lattice Points
Given a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + … + Ak. 继续阅读【矩阵快速幂】Matrix Power Series
A cubic number is the result of using a whole number in a multiplication three times. For example,so
is a cubic number. The first few cubic numbers areand . Given an prime number . Check that if
is a difference of two cubic numbers.
InputThe first of input contains an integer
For each test case, a line contains a prime number .OutputFor each test case, output ‘YES’ if given
is a difference of two cubic numbers, or ‘NO’ if not. 继续阅读【数学】A Cubic number and A Cubic Number