【HDU 5750】Dertouzos(数学)
题目
给定n和d,都是10的9次方以内,求1到n里面有几个数最大因数是d?1000000组数据。
解:求出d的满足p[i]*d<n的最小质因数是第几个质数。即为答案。
#include<cstdio>
#define N 100002
int t,n,d,pr[N],p[N],num;
int main(){
for(int i=2;i<N;i++)if(!pr[i]){
for(int j=i+i;j<N;j+=i)
pr[j]=1;
p[++num]=i;
}
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&d);
int k=1;
for(int i=1;i<=num&&p[i]<=d&&p[i]*d<n;i++){
if(d%p[k]==0)
break;
k++;
}
if(p[k]>d||p[k]*d>n)k--;
printf("%d\n",k);
}
}
【HDU 5750】Dertouzos(数学)的更多相关文章
- 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的另一个乘数是多少 ...
- 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(最大真约数、最小素因子)
Problem Description A positive proper divisor is a positive divisor of a number n, excluding n itsel ...
- HDU 5673 Robot 数学
Robot 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5673 Description There is a robot on the origi ...
- HDU 5914 Triangle 数学找规律
Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, who ...
- HDU 2493 Timer 数学(二分+积分)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2493 题意:给你一个圆锥,水平放置,圆锥中心轴与地面平行,将圆锥装满水,在圆锥某一表面开一个小洞,流出来 ...
- HDU 1568 Fibonacci 数学= = 开篇
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1568 分析:一道数学题 找出斐波那契数列的通项公式,再利用对数的性质就可得到前几位的数 斐波那契通项公 ...
随机推荐
- Github 安全类Repo收集整理
作者:天谕链接:https://zhuanlan.zhihu.com/p/21380662来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处.刚好这两天对之前github上关 ...
- poj2676 Sudoku
Sudoku Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 17953 Accepted: 8688 Special ...
- swift三方库
链接: Swift 有哪些优秀的第三方库? Swift 中AFNetworking 的替代方案 Alamofire Swift2.0后Alamofire的使用方法 [快速学会Swift第三方库] Al ...
- X200s,Debian 8(Jessie) 安装流水帐
1. U盘启动安装 a. 因为无线网卡驱动是non-free,需要另外下载,对应X200s,文件是iwlwifi-5000-5.ucode,下完放到安装U盘的根目录下,安装时就不会再提示而是直接安装 ...
- page-cache层
pagecache层内存管理 如果使用page,尤其对于32位系统来说,kmap & kunmap,可以把做struct *page与虚拟地址的映射 用kmap做一个临时的映射,然后通过kun ...
- 用sql查询当天,一周,一个月的数据
用sql查询当天,一周,一个月的数据 数据查询,不管在网站还是在系统,都很常见,下文是介绍最常见的以日期查询的语句 select * from ShopOrder where datediff(w ...
- LeetCode 01 Two Sum swift
class TwoSum { func sumTow(nums: [Int], target: Int)->[Int]{ ,]; ;x<nums.count;x++){ ;y<num ...
- linux查看出口ip 及w3m字符浏览器
Linux 查看服务器出口IP 字符浏览器: http://wiki.ubuntu.org.cn/W3m
- shell 脚本替换文件中某个字符串
1.将当前目录下包含jack串的文件中,jack字符串替换为tom sed -i "s/jack/tom/g" `grep "jack" -rl ./` 2.将 ...
- C语言 自动修改文件名小程序
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <stri ...