题解报告: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的问题,我们不难联想到<主旋律>这一道题 没错,只需要把方程改一 ...
随机推荐
- 【APUE】进程间通信之管道
管道是UNIX系统IPC最古老形式,并且所有UNIX系统都提供此种通信机制.管道由下面两种局限性: 1)历史上,它们是半双工的(即数据只能在一个方向上流动) 2)它们只能在具有公共祖先的进程之间使用. ...
- ScrollView阻尼效果
activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android&qu ...
- 关键路径(AOE)---《数据结构》严蔚敏
// exam1.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> #include &l ...
- java实现从报文中获取投保单号
java实现从报文中获取投保单号 投保单号正则表达式: String regex = "<proposalNo>([0-9]+)</proposalNo>[\\s\\ ...
- mysql数据库存放路径
在你的my.ini 文件中定义的参数 datadir 指定的目录中. SQL code ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 mysql> select @@da ...
- iOS设备,fixed布局出问题
window.deviceId = '{{$deviceId}}'; window.iOS = navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? t ...
- UWP开发入门系列笔记之(零):UWP的前世今生
引言 在本篇文章中,可以掌握以下知识: 设备族群,如何决定目标设备 新的UI控件和新面板帮助你适应不同的设备特征 从Windows 8系统开始,微软就 引入了WindowsRT(Windows Run ...
- Expression Blend实例中文教程(11) - 视觉管理器快速入门Visual State Manager(VSM)
Expression Blend实例中文教程(11) - 视觉管理器快速入门Visual State Manager(V 时间:2010-04-12 16:06来源:SilverlightChina. ...
- BZOJ_3209_花神的数论题_组合数+数位DP
BZOJ_3209_花神的数论题_组合数+数位DP Description 背景 众所周知,花神多年来凭借无边的神力狂虐各大 OJ.OI.CF.TC …… 当然也包括 CH 啦. 描述 话说花神这天又 ...
- Watir: 很久以前,对Watir开始学习时候做的笔记
1). buttons Xpath 1)Button properties browser.button(:xpath,"//input[@id='b2']/").name bro ...