**质因子个数
来源:互联网 发布:阿里云ecs绑定域名 编辑:程序博客网 时间:2024/06/05 14:16
Description
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.
Sample Input
23 16 3
25
题意:
两个士兵在玩一个游戏,开始的时候第一个士兵选择一个数n,并把这个数交给第二个士兵,第二个士兵必须选择一个x满足x>1 且n能被x整除,然后将n变为n/x,然后把这个数交给第一个士兵,依次循环,当n等于1时,游戏结束,第二个士兵所得的分数为他执行的游戏轮数(选择x的次数)。
为了使游戏更有趣…,第一个士兵选择的n满足如下的形式 a!/b!(a>=b), a!表示a的阶乘。
第二个士兵得到的最大分数是多少?
题解:给出一个n,n开始是a!/b!,每次用一个x去整除n得到新的n,
最后当n变成1的时候经过了几轮得分就是这个轮数,
要求最大的分数是多少
[solve]
就是一个求整数质因子个数的题目,
阶乘我们不需要算,我们知道在a>b的时候,
b!都约掉了,那么我们只需计算出每个数的质因数有几个,
然后前缀和计算出1~n的质因子之和,
告诉你a, b的值, 那么只需要求出b到a之间的数, 每个数有多少个因子就可以。
起初没看懂题,后来百度了一下题解,基本上都是这个思路。。。
- 质因子个数统计
- **质因子个数
- 因子和因子个数
- 求质因子个数的方法
- 求质因子个数的方法
- 求n的质因子的个数
- 统计阶乘中质因子的个数
- N!含有质因子2的个数
- RGCDQ(求质因子个数+规律)
- 奇因子个数
- POJ2992 Divisors【因子个数】
- 【PAT】因子个数
- POJ 2992 因子个数
- 问题 M: 因子个数
- CCF NOI1024 因子个数
- 因子个数打表
- 1303: 因子个数
- CCF 1024 因子个数
- Windows和Linux互相访问远程桌面
- 那些年在前端踩的坑
- MATLAB数据分析与挖掘实战-数据探索-3.1 数据质量分析
- java的instanceof的用法
- 联想拯救者ISK游戏本加装固态硬盘和系统迁移
- **质因子个数
- C和指针(Chapter3 &Chapter4)
- 华为OJ——密码强度等级
- C++ STL算法系列4---unique , unique_copy函数
- 88. Merge Sorted Array
- Spring学习笔记2
- 华为OJ——扑克牌大小
- HDU 1398 Square Coin(简单完全背包)
- Android开发之app崩溃日志收集以及上传