题目传送门 /* 题意:b+1,b+2,...,a 所有数的素数个数和 DP+埃氏筛法:dp[i] 记录i的素数个数和,若i是素数,则为1:否则它可以从一个数乘以素数递推过来 最后改为i之前所有素数个数和,那么ans = dp[a] - dp[b]: 详细解释:http://blog.csdn.net/catglory/article/details/45932593 */ #include <cstdio> #include <algorithm> #include <cs…
题目传送门 /* 题意:这题就是求b+1到a的因子个数和. 数学+DP:a[i]保存i的最小因子,dp[i] = dp[i/a[i]] +1;再来一个前缀和 */ /************************************************ Author :Running_Time Created Time :2015-8-1 14:08:34 File Name :B.cpp ************************************************…
D. Soldier and Number Game Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/546/problem/D Description Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second s…
D. Soldier and Number Game time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the…
D. Soldier and Number Game time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the…
题意 给你a,b(1<=b<=a<=5000000)表示a!/b!表示的数,你每次可以对这个数除以x(x>1且x为这个数的因子)使他变成a!/b!/x, 问你最多可以操作多少次使这个数变成1 http://codeforces.com/problemset/problem/546/D 思路 显然要素因子分解,但直接计算a!/b!的素因子个数太慢了,可以发现实际上是计算a(a-1)(a-2)--(b+1),而这些数之积的所有素因子个数之和是等于每个数的素因子个数之和的(相当于对每一个…
D. Soldier and Number Game time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output -> Link <- 题目链接呈上: 题意:两个人玩游戏,其中一个人选一个数n给另外一个人,然后每轮选一个数x使得n能被x整除,然后用n/=x;注意x>1:问要使得另一个人得分最高,最高多少:即最多能够玩几轮n变成了1…
题目传送门 /* 题意:两堆牌,每次拿出上面的牌做比较,大的一方收走两张牌,直到一方没有牌 queue容器:模拟上述过程,当次数达到最大值时判断为-1 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <stack> #include <cmath> #inc…
题目传送门 /* 题意:问最少增加多少值使变成递增序列 贪心:排序后,每一个值改为前一个值+1,有可能a[i-1] = a[i] + 1,所以要 >= */ #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long ll; ; const int INF = 0x3f3f3f3f; int a[MAXN]; int main(vo…
题目传送门 /* 水题:ans = (1+2+3+...+n) * k - n,开long long */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; typedef long long ll; int main(void) //Codeforces Round #304 (Div. 2) A. Soldier…