codeforces 546 D
来源:互联网 发布:软件专利说明书 编辑:程序博客网 时间:2024/06/06 04:55
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x > 1, such that n is divisible by x and replacing n with n / x. When n becomes equal to 1 and there is no more possible valid moves the game is over and the score of the second soldier is equal to the number of rounds he performed.
To make the game more interesting, first soldier chooses n of form a! / b! for some positive integer a and b (a ≥ b). Here by k! we denote the factorial of k that is defined as a product of all positive integers not large than k.
What is the maximum possible score of the second soldier?
First line of input consists of single integer t (1 ≤ t ≤ 1 000 000) denoting number of games soldiers play.
Then follow t lines, each contains pair of integers a and b (1 ≤ b ≤ a ≤ 5 000 000) defining the value of n for a game.
For each game output a maximum score that the second soldier can get.
23 16 3
25
从今往后。。。我再也不信任CF的机器了。。竟然卡iostream。。。我的天
#include <bits/stdc++.h>using namespace std;int ps[5000010];int main(){for(int i=2;i<5000000;i++)if(ps[i]==0)for(int j=i;j<=5000000;j+=i)ps[j]=ps[j/i]+1;for(int i=1;i<=5000000;i++)ps[i]+=ps[i-1];int n;cin>>n;while(n--){int a,b;scanf("%d%d",&a,&b);printf("%d\n",ps[a]-ps[b]);}}
- codeforces 546D
- codeforces 546 D
- codeforces 546D (数学 水)
- CodeForces 546D Soldier and Number Game
- CodeForces-546D Soldier and Number Game
- Codeforces 546D Soldier and Number Game
- CodeForces 546D (求素因子个数)
- CodeForces-546D.Soldier and Number Game
- CodeForces 546D (质因子打表法)
- codeforces 546D. Soldier and Number Game
- CodeForces 546D Soldier and Number Game
- 【codeforces 546D】Soldier and Number Game
- CodeForces 546D(求质因数的个数)
- CodeForces 617D CodeForces 617D
- CodeForces 101D
- CodeForces 103D
- CodeForces 222D Olympiad
- codeforces 242d
- Linux 软件包管理
- Failed to connect to remote VM. Connection refused. Connection refused: connect
- mini2440系统移植篇之kernel编译
- mini2440系统移植篇之kernel链接
- 父类指针指向子类对象的理解
- codeforces 546 D
- Opacity多浏览器透明度兼容处理
- 获取手机信息的工具类
- C# 在程序焦点之外捕捉按键操作(键盘钩子的使用)
- python笔记15--django之web(MVC模式)
- PES/TS/ES
- leetcode - Regular Expression Matching
- 关于Handler Runnable和Thread的一些看法
- [Lintcode] Best Time to Buy and Sell Stock IV