0w1

Entries from 2016-07-27 to 1 day

CFR 615 D. Multipliers ( Math )

Problem - D - Codeforces The number that some prime would be involved in the multiplication, is the cumulative product of the count of power for all other primes, again multiplied by ( 1 + 2 + .. + c ), where c is the count of power of the…

CFR 177 B2. Rectangular Game ( DP )

Problem - B2 - Codeforces Having done so many ( not really many though ) problems, I always warn myself to think of an easier solution. Anyways, this could be solved with DP. Since MAXN = 1e9, and 2*3*7*11*13*17*19*31*37 ≥ 2e9, there will …

CFR 82 C. Buns ( DP, Knapsack )

Problem - 106C - Codeforces I do seriously doubt the tag is nonsense. Anyways, for the buns that do not require stuffings, we will do infinite knapsack. For the buns that need stuffings, simply do multiple knapsacks. const int MAXN = 1e3 +…

CFR 453 1A. Little Pony and Expected Maximum ( Math, Expectancy )

http://codeforces.com/problemset/status The number of situations such that the face x is of the maximum, is ( x^n - ( x - 1 )^n ). So the expectancy we are looking for can be calculated as However, simply implementing this, you will find i…

CFR 599 D. Spongebob and Squares ( Math )

Problem - D - Codeforces Without losing generality, let n ≤ m, we are to find all such pairs ( n, m ) that satisfy: Do a little math and we will conclude that Since n ≤ m, the upper bound of n is of some constant multiple of X^( 1 / 3 ). T…

隨機算法快速判斷質數 O( lg V )

對因數分解困惑的時候剛好經過這個文章: 如何快速验证一个超大的数为质数 - SegmentFault 以前是聽過麻煩的 Miller-Rabin偽素數檢驗法,倒是沒聽過除此之外有這麼簡潔的隨機算法可以快速判斷是否質數。原理是根據 Fermat's little theorem: a ^ ( p - 1 ) =…