HDU 5750 Dertouzos
Dertouzos
Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 577 Accepted Submission(s): 160
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.
The first line contains two integers n and d (2≤n,d≤109).
#include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <sstream>
#define lson l,m,rt*2
#define rson m+1,r,rt*2+1
#define mod 1000000007
#define INF 1000000006
using namespace std;
typedef long long LL;
int n,d,k,p;
vector<LL> Q;
bool vis[+];
void init()
{
for(LL i=;i<=+;i++)
{
if(!vis[i])
{
Q.push_back(i);
for(LL j=i*i;j<=+;j+=i)
{
vis[j]=true;
}
}
}
}
int main()
{
#ifdef Local
freopen("data.txt","r",stdin);
#endif
int T,i,j,h,r,sum=,m,ans,flag,q,mid,l;
cin>>T;
init();
while(T--)
{
ans=flag=;
scanf("%d%d",&n,&d);
n=(n-)/d;
for(i=;Q[i]<=n&&i<Q.size();i++)
{
ans++;
if((d%Q[i])==)break;
}
cout<<ans<<endl;
}
}
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 简单数学
感悟:这又是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(数学)
题目给定n和d,都是10的9次方以内,求1到n里面有几个数最大因数是d?1000000组数据.解:求出d的满足p[i]*d<n的最小质因数是第几个质数.即为答案. #include<cst ...
- hdu 5750(数论)
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 ...
- Dertouzos (5750)
Dertouzos 题意: 就是给一个n和一个d,问有多少个小于n的数的最大因子是d. 分析: 如果一个数是质数,又和d互质,它们的乘积在范围内的话显然是满足条件的, 如果这个质数和d不互质,那么如果 ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
随机推荐
- 小笔记(三):PHP使用thinkphp3.2.3对数组进行分页
之前写过thinkphp3.2.3直接在查询数据的时候进行分页,前段时间用到了将查询之后的数组进行整理后进行分页,用到的一个函数array_slice($arr, $start, $length,tr ...
- vagrant 设置除默认工项目之外的synced_folder一个坑
vagrant和host共享的目录,模式是以host主机目录为主,vagrant目录为从,所以记住当你新建同步目录的时候一定要先把vagratn目录文件备份一下,不然会被host目录覆盖
- Building Python 2.7.10 with Visual Studio 2010 or 2015 - Google Chrome
您的浏览器(Chrome 33) 需要更新.该浏览器有诸多安全漏洞,无法显示本网站的所有功能. 了解如何更新浏览器 × p-nand-q.com C++ Python Programming L ...
- Linux Makefile analysis for plain usr
一.本文主旨 笔者写了一篇linux内核Makefile整体分析 ,测重于理论分析,对于实际应用不算对头,所以需要写一篇实用性较强的文章,为以后内核.驱动移植做好铺垫. 二.本文内容概要 1.编译哪些 ...
- AirPlay简介
AirPlay是苹果公司在iOS4.2即Mac OS Mountain Lion中加入的一种播放技术.可以将iPhone.iPod.iPad和Mac上的视频镜像传送到支持AirPlay的设备上(如音响 ...
- iOS分类中通过runtime添加动态属性
这个的话并不是说 可以 在程序运行的时候 来几个 未知的东西 就添加什么 1 2 3 4 5的属性.而是可以在系统原有类的基础上 给那个类 集合实际的工程来添加你方便实用的东西.比如 ...
- 运行avalon.define()发生的事情
avalon.define = function(id, factory) { var $id = id.$id || id if (!$id) { log("warning: vm必须 ...
- 【Tools】Chrome开发者工具详解
作为一名前端开发者,打交道最多的可能是和浏览器.市面上各种浏览器多不胜数,主流的有Chrome,Firefox,Safari,IE,Opera,非主流的如360,遨游,QQ浏览器,搜狗浏览器,据说淘宝 ...
- QLGame 2D Engine编写环境搭建
QLGame 2D Engine编写 (win7环境搭建) 广州麒麟网络工作室,计划制作一款2d game engine,基于opengl(es)平台,暂时支持android,以后考虑支持linux, ...
- 不可忽视的 .NET 应用5大性能问题
[编者按]本文系国内 ITOM 管理平台 OneAPM 翻译自 Steven Haines 的文章.Steven Haines 是 Pisksel 技术架构师,目前在奥兰多迪士尼乐园工作.他是在线教育 ...