[CF653G]Move by Prime 题意:给你一个长度为n的数列$a_i$,你可以进行任意次操作:将其中一个数乘上或者除以一个质数.使得最终所有数相同,并使得操作数尽可能小.现在我们想要知道$a_i$的所有子序列的操作数之和是多少.答案对$10^9+7$取模. $n,a_i\le 3\times 10^5$ 题解:显然要对每个质数分别处理.而对于每个质数,最终一定是让所有数都变成该序列的中位数最优.因此如果所有数的次数分别是$k_1,k_2...k_n$,则如果i在中位数左边,则贡献为$…
Sieve of Eratosthenes (素数筛选算法) Given a number n, print all primes smaller than or equal to n. It is also given that n is a small number. For example, if n is 10, the output should be “2, 3, 5, 7″. If n is 20, the output should be “2, 3, 5, 7, 11, 13,…
DP? Problem Description Figure 1 shows the Yang Hui Triangle. We number the row from top to bottom 0,1,2,…and the column from left to right 0,1,2,….If using C(n,k) represents the number of row n, column k. The Yang Hui Triangle has a regular pattern…
Prime Ring Problem Time Limit : 4000/2000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 18 Accepted Submission(s) : 7 Problem Description A ring is compose of n circles as shown in diagram. Put natural number 1, 2,…
J. Ceizenpok’s formula time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Dr. Ceizenp'ok from planet i1c5l became famous across the whole Universe thanks to his recent discovery — the Ceizenp…