Dertouzos (5750)
题意:
就是给一个n和一个d,问有多少个小于n的数的最大因子是d。
分析:
如果一个数是质数,又和d互质,它们的乘积在范围内的话显然是满足条件的,
如果这个质数和d不互质,那么如果只有这个质数是d最小的质因子时才满足这个条件,其他都不满足,
9
10 2
10 3
10 4
10 5
10 6
10 7
10 8
10 9
100 13
1
2
1
0
0
0
0
0
4
#include <cstdio>
#include <iostream>
#define LL long long
const int maxn=;
using namespace std;
int vis[maxn];
LL a[maxn];
int main()
{
LL n,d;
int num=;
for(LL i=;i<maxn;i++)
{
if(vis[i]==) a[num++]=i;
for(LL j=;j*i<maxn;j++)
vis[i*j]=;
}
int t;
scanf("%d",&t);
while(t--)
{
LL ans=;
scanf("%lld%lld",&n,&d);
if(n<=d)
{
printf("0\n");
continue;
}
for(int i=;i<num;i++)
{
if(d<a[i]) break;
else if(d%a[i]!=&&d*a[i]<n) ans++;
else if(d%a[i]==&&d*a[i]<n) {ans++; break;}
else break; //d*a[i]>=n
}
printf("%lld\n",ans);
}
return ;
}
Dertouzos (5750)的更多相关文章
- hdu 5750 Dertouzos 素数
Dertouzos Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total ...
- BestCoder HDU 5750 Dertouzos
Dertouzos 题意: 有中文,不说. 题解: 我看了别人的题解,还有个地方没懂, 为什么是 if(d%prime[i]==0) break; ? 代码: #include <bits/st ...
- HDU 5750 Dertouzos
Dertouzos Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total ...
- hud 5750 Dertouzos
Dertouzos Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total ...
- 【HDU 5750】Dertouzos(数学)
题目给定n和d,都是10的9次方以内,求1到n里面有几个数最大因数是d?1000000组数据.解:求出d的满足p[i]*d<n的最小质因数是第几个质数.即为答案. #include<cst ...
- HDU 5750 Dertouzos 简单数学
感悟:这又是zimpha巨出的一场题,然后04成功fst(也就是这题) 实际上还是too young,要努力增加姿势, 分析:直接枚举这些数不好枚举,换一个角度,枚举x*d,也就是d的另一个乘数是多少 ...
- 题解报告:hdu 5750 Dertouzos(最大真约数、最小素因子)
Problem Description A positive proper divisor is a positive divisor of a number n, excluding n itsel ...
- hdu 5750(数论)
Dertouzos Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total ...
- hdu-5750 Dertouzos(数论)
题目链接: Dertouzos Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Other ...
随机推荐
- .NET MVC Filter异常处理
MVC程序中自带的HandleErrorAttribute,来处理异常,不在显示黄页.前提是在web.config 中 system.web中关闭customerError选项. 但是很多情况下调试异 ...
- java 文件保存到本地
private void savePic(InputStream inputStream, String fileName) { OutputStream os = null; try { Strin ...
- html5 canvas 实现倒计时 功能
function showTime(a) { var b = { id: "showtime", //canvasid x: 60, //中心点坐标 X轴; y: 60, //中心 ...
- Demo中的IOC自定义实现
在做练习的时候,小小项目,使用IOC控件觉得麻烦,使用工厂觉得不高大上啊,自己写个简陋的依赖注入IOC吧; 控制反转(IOC)是管理映射依赖的的,是依赖倒置(DIP)的实现方式; 依赖倒置(DIP)是 ...
- Python: Win7 64位如何安装MongoDB?
Windows 7 64位安装MongoDB 官网tutorial: https://docs.mongodb.com/v3.0/tutorial/install-mongodb-on-window ...
- MySql 里的IFNULL、NULLIF和ISNULL用法
MySql 里的IFNULL.NULLIF和ISNULL用法 mysql中isnull,ifnull,nullif的用法如下: isnull(expr) 的用法: 如expr 为null,那么isnu ...
- sublime text 2 快捷键
快捷键 功能 ctrl+shift+n 打开新Sublime ctrl+shift+w 关闭Sublime,关闭所有打开文件 ctrl+shift+t 重新打开最近关闭文件 ctrl+n 新建文件 c ...
- Shell 字符串的截取
直接上代码了. linux-:/.sh #!/bin/sh STR=HelloWorld echo 'STR == ' $STR :} # == } #结果为World } # Use : ${STR ...
- C#递归、动态规划计算斐波那契数列
//递归 public static long recurFib(int num) { if (num < 2) ...
- centos 使用 locate
centos 第一次使用locate时报错: locate: can not stat () `/var/lib/mlocate/mlocate.db': 没有那个文件或目录 因为locate相关的索 ...