Dertouzos

题意:

就是给一个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)的更多相关文章

  1. hdu 5750 Dertouzos 素数

    Dertouzos Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  2. BestCoder HDU 5750 Dertouzos

    Dertouzos 题意: 有中文,不说. 题解: 我看了别人的题解,还有个地方没懂, 为什么是 if(d%prime[i]==0) break; ? 代码: #include <bits/st ...

  3. HDU 5750 Dertouzos

    Dertouzos Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  4. hud 5750 Dertouzos

    Dertouzos Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  5. 【HDU 5750】Dertouzos(数学)

    题目给定n和d,都是10的9次方以内,求1到n里面有几个数最大因数是d?1000000组数据.解:求出d的满足p[i]*d<n的最小质因数是第几个质数.即为答案. #include<cst ...

  6. HDU 5750 Dertouzos 简单数学

    感悟:这又是zimpha巨出的一场题,然后04成功fst(也就是这题) 实际上还是too young,要努力增加姿势, 分析:直接枚举这些数不好枚举,换一个角度,枚举x*d,也就是d的另一个乘数是多少 ...

  7. 题解报告:hdu 5750 Dertouzos(最大真约数、最小素因子)

    Problem Description A positive proper divisor is a positive divisor of a number n, excluding n itsel ...

  8. hdu 5750(数论)

    Dertouzos Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  9. hdu-5750 Dertouzos(数论)

    题目链接: Dertouzos Time Limit: 7000/3500 MS (Java/Others)     Memory Limit: 131072/131072 K (Java/Other ...

随机推荐

  1. javascript export excel

    <input type="button" onclick="tableToExcel('tablename', 'name')" value=" ...

  2. 为什么使用Junit Test而不用普通java main方法来完成测试?

    因为在程序里边,一个接口对应一个实现方法,而在接口中常常会定义相关的很多方法,所以在测试的时候,如果都在main方法里边进行测试,main方法就会显得臃肿,而且不便于以后其他人测试以及查看测试数据,用 ...

  3. iOS UIAlertController跟AlertView用法一样 && otherButtonTitles:(nullable NSString *)otherButtonTitles, ... 写法

    今天写弹出框UIAlertController,用alertView习惯了,所以封装了一下,跟alertView用法一样,不说了,直接上代码: 先来了解一下otherButtonTitles:(nul ...

  4. 解决java.lang.NoClassDefFoundError: org/objectweb/asm/util/TraceClassVisitor

    方案一: <dependency> <groupId>asm</groupId> <artifactId>asm-all</artifactId& ...

  5. for_each(c++11)

    http://www.cplusplus.com/reference/algorithm/for_each/ template<class InputIterator, class Functi ...

  6. Docker(一)

    Docker是一个能够把开发的应用程序自动部署到容器的开源引擎,它基于Apache2.0开源授权协议发行,以Docker容器为资源分割和调度的基本单位,封装整个软件运行时环境,为开发者和管理员设计的, ...

  7. C#中常用的系统内置委托

    在公共语言运行时(CLR)环境中系统为我们内置了一些常用的委托,包括Action类的委托.Func类的委托.Predicate<T>委托.Comparison<T>委托等等.以 ...

  8. Scrapy 爬虫 使用指南 完全教程

    scrapy note command 全局命令: startproject :在 project_name 文件夹下创建一个名为 project_name 的Scrapy项目. scrapy sta ...

  9. Centos7 关闭防火墙(转)

    转载地址:http://www.cnblogs.com/silent2012/archive/2015/07/28/4682770.html CentOS 7.0默认使用的是firewall作为防火墙 ...

  10. webview页面缩放 & 自适应

    0.webview页面自适应: // 1.LayoutAlgorithm.NARROW_COLUMNS : 适应内容大小// 2.LayoutAlgorithm.SINGLE_COLUMN:适应屏幕, ...