Soldier and Number Game-素数筛
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?
Input
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.
Output
For each game output a maximum score that the second soldier can get.
Examples
2
3 1
6 3
2
5
Soldier and Number Game-素数筛的更多相关文章
- Codeforces Round #304 (Div. 2) D. Soldier and Number Game 素数打表+质因数分解
D. Soldier and Number Game time limit per test 3 seconds memory limit per test 256 megabytes input s ...
- zoj3886--Nico Number(素数筛+线段树)
Nico Number Time Limit: 2 Seconds Memory Limit: 262144 KB Kousaka Honoka and Minami Kotori are ...
- Codeforces J. Soldier and Number Game(素数筛)
题目描述: Soldier and Number Game time limit per test 3 seconds memory limit per test 256 megabytes inpu ...
- Soldier and Number Game CodeForces - 546D 素因子数打表(素数筛的改造)
题意: 输入 a 和 b(a>b),求a! / b!的结果最多能被第二个士兵给的数字除多少次. 思路: a! / b!肯定能把b!约分掉,只留下b+1~a的数字相乘,所以我们求b+1 ~ a的所 ...
- codeforces Soldier and Number Game(dp+素数筛选)
D. Soldier and Number Game time limit per test3 seconds memory limit per test256 megabytes inputstan ...
- Help Hanzo (素数筛+区间枚举)
Help Hanzo 题意:求a~b间素数个数(1 ≤ a ≤ b < 231, b - a ≤ 100000). (全题在文末) 题解: a~b枚举必定TLE,普通打表MLE,真是头疼 ...
- SDUT Fermat’s Chirstmas Theorem(素数筛)
Fermat's Chirstmas Theorem Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描写叙述 In a letter ...
- poj2739尺取法+素数筛
Some positive integers can be represented by a sum of one or more consecutive prime numbers. How man ...
- hdu2421(数学,因式分解素数筛)
Xiaoming has just come up with a new way for encryption, by calculating the key from a publicly view ...
随机推荐
- Shiro学习(17)OAuth2集成
目前很多开放平台如新浪微博开放平台都在使用提供开放API接口供开发者使用,随之带来了第三方应用要到开放平台进行授权的问题,OAuth就是干这个的,OAuth2是OAuth协议的下一个版本,相比OAut ...
- SCP-bzoj-1068
项目编号:bzoj-1068 项目等级:Safe 项目描述: 戳这里 特殊收容措施: 区间DP.f[l][r][s]表示l到r的子串能最小被压成的长度,其中s∈[0,1]表示该串压缩后串中是否能含有M ...
- Linux下安装PHP的mcrypt扩展
首先下载,并安装 libmcrypt-2.5.8.tar.gz 下载地址: http://sourceforge.net/project/showfiles.php?group_id=87941&am ...
- html常用标签梳理
标签的语法 标签由英文尖括号<和>括起来,如<html>就是一个标签. html中的标签一般都是成对出现的,分开始标签和结束标签.结束标签比开始标签多了一个/. 如: (1)& ...
- ProcessFun
#pragma once #ifndef __PROCESSFUN_H__ #define __PROCESSFUN_H__ #include <iostream> #include &l ...
- 杂项:SVN -u
ylbtech-杂项:SVN 1.返回顶部 2.返回顶部 3.返回顶部 4.返回顶部 5.返回顶部 6.返回顶部 7.返回顶部 8.返回顶部 9.返回顶部 10 ...
- cd 命令行进入目标文件夹
当我在默认路径中使用cd命令时,如果我要进入D:\mytext 文件夹,那么直接使用cd D:\mytext 是不行的 正确的使用是先使用d:进入D盘,然后再进入mytext文件夹
- monkeyrunner 进行多设备UI测试
monkeyrunner进行多设备UI测试 首先你要连接好多个手机设置好已经连接好的手机的ip列表ipp = ['192xxx','192xxx']杀掉之前所有appium进程subprocess. ...
- POJ 1269 Intersecting Lines (判断直线位置关系)
题目链接:POJ 1269 Problem Description We all know that a pair of distinct points on a plane defines a li ...
- 剑指offer——70n个骰子的点数
题目: 把n个骰子扔在地上,所有骰子朝上一面的点数之和为s.输入n,打印出s的所有可能的值出现的概率. 题解: 使用两个数组存每次投的点数 void theProbability(const int ...