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 ...
随机推荐
- c# winform textbox与combox让用户不能输入
textbox的ReadOnly属性设置为true combox的Enable属性设置为false 运行后效果如下 点击第一个和第二个,会把按钮text赋值给文本框和combox 并且用户不能输入
- React组件二
<script type="text/babel"> <!-- this.props.children表示读取组件的所有子节点-->var Zu=React ...
- Laravel学习第一天(创建laravel项目、路由、视图、blade模板)
创建laravel项目 composer create-project laravel/laravel learnlv 4.1.* 查看帮助:composer create-project 使用 ...
- 【转】mybatis在xml文件中处理大于号小于号的方法
http://blog.csdn.net/zheng0518/article/details/10449549 第一种方法: 用了转义字符把>和<替换掉,然后就没有问题了. SELECT ...
- Case When PK PIVOT
SELECT *FROM ScoreInfogo Name Course Score---------- ---------- -----------Lucy Chinese 74Jim Math 8 ...
- 【HDU 1533】 Going Home (KM)
Going Home Problem Description On a grid map there are n little men and n houses. In each unit time, ...
- ANDROID_MARS学习笔记_S03_006_geocoding、HttpClient
一.简介 二.代码1.xml(1)AndroidManifest.xml <uses-permission android:name="android.permission.ACCES ...
- Mono for Android 优势与劣势
原文:Mono for Android 优势与劣势 最近有兴趣了解一下Mono for Andriod,也就是使用.NET平台来开发Andriod程序.Mono for Android API 几乎映 ...
- [QuickX]xcode运行Quick-cocos2d-x项目时自动更新lua资源文件
1.项目设置 build settings ->build options ->Scan all source files and Includes = YES 2.加入script (1 ...
- 【HDOJ】3277 Marriage Match III
Dinic不同实现的效率果然不同啊. /* 3277 */ #include <iostream> #include <string> #include <map> ...