题解报告:hdu 5750 Dertouzos(最大真约数、最小素因子)
Problem Description
Peter has two positive integers n and d. He would like to know the number of integers below n whose maximum positive proper divisor is d.
Input
The first line contains two integers n and d (2≤n,d≤109).
Output
Sample Input
Sample Output
#include<bits/stdc++.h>
using namespace std;
const int maxn=;//只需得到sqrt(1e9)=31622.8(取比31622.8大一点的整数31650)内的所有质数即可
int t,n,d,cnt=,prime[maxn];bool isp[maxn];
void euler_sieve(){
memset(isp,true,sizeof(isp));
isp[]=isp[]=false;
for(int i=;i<maxn;++i){
if(isp[i])prime[cnt++]=i;
for(int j=;j<cnt&&i*prime[j]<maxn;++j){
isp[i*prime[j]]=false;
if(i%prime[j]==)break;
}
}
}
int main(){
euler_sieve();
while(~scanf("%d",&t)){
while(t--){
scanf("%d%d",&n,&d);
int num=,border=min(d,(n-)/d);
for(int i=;prime[i]<=border;++i){
num++;
if(d%prime[i]==)break;//至多找到d的最小质因子即可
}
printf("%d\n",num);
}
}
return ;
}
题解报告:hdu 5750 Dertouzos(最大真约数、最小素因子)的更多相关文章
- 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 ...
- HDU 5750 Dertouzos 简单数学
感悟:这又是zimpha巨出的一场题,然后04成功fst(也就是这题) 实际上还是too young,要努力增加姿势, 分析:直接枚举这些数不好枚举,换一个角度,枚举x*d,也就是d的另一个乘数是多少 ...
- 题解报告:hdu 1398 Square Coins(母函数或dp)
Problem Description People in Silverland use square coins. Not only they have square shapes but also ...
- 题解报告:hdu 2069 Coin Change(暴力orDP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2069 Problem Description Suppose there are 5 types of ...
- 题解报告:hdu 1028 Ignatius and the Princess III(母函数or计数DP)
Problem Description "Well, it seems the first problem is too easy. I will let you know how fool ...
- 2015浙江财经大学ACM有奖周赛(一) 题解报告
2015浙江财经大学ACM有奖周赛(一) 题解报告 命题:丽丽&&黑鸡 这是命题者原话. 题目涉及的知识面比较广泛,有深度优先搜索.广度优先搜索.数学题.几何题.贪心算法.枚举.二进制 ...
- cojs 强连通图计数1-2 题解报告
OwO 题目含义都是一样的,只是数据范围扩大了 对于n<=7的问题,我们直接暴力搜索就可以了 对于n<=1000的问题,我们不难联想到<主旋律>这一道题 没错,只需要把方程改一 ...
随机推荐
- idea、jdk、eclispe中空main方法的线程数量不一样,why?
測试代码: public class Test { public static void main(String[] args) { System.out.println(Th ...
- kvm虚拟化学习笔记(二)之linux kvm虚拟机安装
KVM虚拟化学习笔记系列文章列表----------------------------------------kvm虚拟化学习笔记(一)之kvm虚拟化环境安装http://koumm.blog.51 ...
- apc smart UPS下使用apcupsd注意事项
公司的apc smart UPS安装有管理卡(似乎是AP-9631),server环境有FreeBSD.Windows Server.Linux(CentOS.Ubuntu) 实际使用中有例如以下问题 ...
- Office EXCEL 2010如何启用宏编辑器,打开VB编辑器
文件-选项-主选项卡,勾选开发工具 然后在开发工具中找到Visual Basic编辑器,打开代码
- Failed to load resource: the server responded with a status of 404 (Not Found)
Failed to load resource: the server responded with a status of 404 (Not Found) 报错情况:图标加载失败 原因分析:路径错误 ...
- Python常用的几种常用的内置函数
abs(x) 用于返回绝对值 divmod(x,y) 函数中传入两个数字,返回的是x/y的一个结果的元组(商,余数) pow(x,y) 用于 ...
- Jenkins系列之-—02 email-ext 邮件模板
邮件通知配置 系统管理 → 系统设置 → 邮件通知 SMTP 服务器:配置 SMTP 服务器.(不填默认本地运行服务器) 用户默认邮件后缀:注册用户邮件只需填写用户名即可,后缀会加该后缀,如果填写,则 ...
- soapUI系列之—-03 Groovy脚本常用方法2
------Groovy脚本常用方法 1.解析Json数据脚本 //groovy读取json的方式很简单,re.body.businessinfo.c2rate读取c2rate对应的值 import ...
- Linux学习笔记:系统启动引导过程
Linux系统启动引导过程 近期发现自己在仅仅是掌握上有几个比較硬的伤: 一.知识体系碎片,比方Linux,这学点那学点,结果没有成体系,串不起来: 二.记忆时间短暂,非常多的内容学了就忘,最后的结果 ...
- caution
做好需求更改的准备,提高代码的扩展性和可维护性:预留出修改bug和需求的时间:对需求理解透彻再开始写代码:代码不要写死,防止需求变动.