hdu-5750 Dertouzos(数论)
题目链接:
Dertouzos
Time Limit: 7000/3500 MS (Java/Others)
Memory Limit: 131072/131072 K (Java/Others)
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 <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
//#include <bits/stdc++.h>
#include <stack> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
if(!p) { puts("0"); return; }
while(p) stk[++ tp] = p%10, p/=10;
while(tp) putchar(stk[tp--] + '0');
putchar('\n');
} const LL mod=1e9+7;
const double PI=acos(-1.0);
const int inf=1e9;
const int N=1e5+10;
const int maxn=500+10;
const double eps=1e-8; int prime[N],sum[N],a[N],cnt=0,n,d;
void Init()
{
sum[1]=0;
For(i,2,N-maxn)
{
if(!prime[i])
{
for(int j=2*i;j<N-maxn;j+=i)
{
prime[j]=1;
}
sum[i]=sum[i-1]+1;
}
else sum[i]=sum[i-1];
}
For(i,2,N-maxn)
{
if(!prime[i])a[++cnt]=i;
}
} inline int check(int x)
{
for(int i=1;i<=cnt;i++)
{
if(x%a[i]==0)return a[i];
if((LL)a[i]*a[i]>x||a[i]>n/d)break;
}
return x;
}
int main()
{
int t;
read(t);
Init();
while(t--)
{
read(n);read(d);
n--;
int le=min(check(d),n/d);
printf("%d\n",sum[le]);
} return 0;
}
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 5750 Dertouzos(最大真约数、最小素因子)
Problem Description A positive proper divisor is a positive divisor of a number n, excluding n itsel ...
- hdu 5750(数论)
Dertouzos Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total ...
- 【HDU 5750】Dertouzos(数学)
题目给定n和d,都是10的9次方以内,求1到n里面有几个数最大因数是d?1000000组数据.解:求出d的满足p[i]*d<n的最小质因数是第几个质数.即为答案. #include<cst ...
- hdu GuGuFishtion 6390 数论 欧拉函数
题目:http://acm.hdu.edu.cn/showproblem.php?pid=6390 直接开始证明: 我们设…………………………………….....…...............………… ...
- HDU 1299 基础数论 分解
给一个数n问有多少种x,y的组合使$\frac{1}{x}+\frac{1}{y}=\frac{1}{n},x<=y$满足,设y = k + n,代入得到$x = \frac{n^2}{k} + ...
- HDU 5317 RGCDQ (数论素筛)
RGCDQ Time Limit: 3000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64u Submit Status ...
随机推荐
- Python之Django-part 1
python manage.py syncdb 在django1.7已经被取代了:用python manage.py migrate 代替来移动库: 删除.卸载django 在cd /usr/lo ...
- 使用viewPage实现图片轮播
概述 图片循环播放这种效果,在许多的场合都能看到,只要一打开各大主流网站的首页几乎都有一个这样的组件,它可以很显目的提供给用户最近最火热的信息.因为它应用得如此之广泛,今天,我们就来写一下这个组件. ...
- oracle 查看各表空间剩余量
1.查看所有表空间大小.剩余量: select dbf.tablespace_name,dbf.totalspace "总量(M)",dbf.totalblocks as 总块数, ...
- [ACM] hdu 1217 Arbitrage (bellman_ford最短路,推断是否有正权回路或Floyed)
Arbitrage Problem Description Arbitrage is the use of discrepancies in currency exchange rates to tr ...
- vue 给组件绑定原生事件
有时候,你可能想在某个组件的根元素上监听一个原生事件.可以使用 v-on 的修饰符 .native.例如: <my-component v-on:click.native="doThe ...
- 小贝_mysql select连接查询
select连接查询 简要: 一.union联合查询 二.左右内连接 一.union联合查询 作用: 把2次或多次查询结果合并起来 具体: (表1查询结果) union (表2查询结果) 运行: 先算 ...
- Hadoop学习笔记(一)——Hadoop体系结构
HDFS和MapReduce是Hadoop的两大核心. 整个Hadoop体系结构主要是通过HDFS来实现分布式存储的底层支持的,而且通过MapReduce来实现分布式并行任务处理的程序支持. 一.HD ...
- vue-导入静态文件
vue导入静态文件不用像网上说的那么麻烦,其实跟普通Django项目导入类似,vue项目中有一个static文件,将你的静态文件放入到里面,然后引入就好 导入的时候和普通Django程序类似:↓ &l ...
- 基于tornado实现的web聊天室
目录结构: # -*- coding:utf-8 -*- import uuid import json import tornado.ioloop import tornado.web import ...
- Canvas学习笔记——拖曳与投掷物体
首先用一个例子来演示这个效果: 鼠标可以拖曳和投掷小球 // > 16 & 0xff, g = color >> 8 & 0xff, b = color > ...