hdu 5750(数论)
Dertouzos
Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 891 Accepted Submission(s): 274
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).
10 2
10 3
10 4
10 5
10 6
10 7
10 8
10 9
100 13
2
1
0
0
0
0
0
4
#include<iostream>
#include<cstdio>
#include<cstring>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long LL;
const int N = ;
bool p[N];
int prime[N];
int id;
void init()
{
id = ;
for(int i=; i<N; i++)
{
if(!p[i])
{
prime[++id] = i;
for(LL j=(LL)i*i; j<N; j+=i)
{
p[j] = true;
}
}
}
} int main()
{
init();
int tcase;
scanf("%d",&tcase);
while(tcase--)
{
int n,d;
scanf("%d%d",&n,&d);
int ans = ;
for(int i=; i<=id; i++)
{
if(prime[i]*d>=n) break;
ans++;
if(d%prime[i]==) break;
}
printf("%d\n",ans);
}
return ;
}
hdu 5750(数论)的更多相关文章
- hdu 5750 Dertouzos 素数
Dertouzos Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total ...
- GCD and LCM HDU 4497 数论
GCD and LCM HDU 4497 数论 题意 给你三个数x,y,z的最大公约数G和最小公倍数L,问你三个数字一共有几种可能.注意123和321算两种情况. 解题思路 L代表LCM,G代表GCD ...
- HDU 4497 数论+组合数学
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4497 解题思路:将满足条件的一组x,z,y都除以G,得到x‘,y',z',满足条件gcd(x',y' ...
- hdu 4542 数论 + 约数个数相关 腾讯编程马拉松复赛
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4542 小明系列故事--未知剩余系 Time Limit: 500/200 MS (Java/Others) ...
- hdu 4961 数论?
http://acm.hdu.edu.cn/showproblem.php?pid=4961 给定ai数组; 构造bi, k=max(j | 0<j<i,a j%ai=0), bi=ak; ...
- hdu 1664(数论+同余搜索+记录路径)
Different Digits Time Limit: 10000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- hdu 3641 数论 二分求符合条件的最小值数学杂题
http://acm.hdu.edu.cn/showproblem.php?pid=3641 学到: 1.二分求符合条件的最小值 /*================================= ...
- hdu 4059 数论+高次方求和+容斥原理
http://acm.hdu.edu.cn/showproblem.php? pid=4059 现场赛中通过率挺高的一道题 可是容斥原理不怎么会.. 參考了http://blog.csdn.net/a ...
- 【HDU 5750】Dertouzos(数学)
题目给定n和d,都是10的9次方以内,求1到n里面有几个数最大因数是d?1000000组数据.解:求出d的满足p[i]*d<n的最小质因数是第几个质数.即为答案. #include<cst ...
随机推荐
- delphi RGB与TColor的转换
1.RGB转换为Tcolor function RGBToColor(R,G,B: byte): Tcolor;begin Result := B Shl 16 or G shl 8 or R;e ...
- java 使用ByteArrayOutputStream和ByteArrayInputStream实现深拷贝
首先介绍Java中的浅拷贝(浅克隆)和深拷贝(深克隆)的基本概念: 浅拷贝: 被复制对象的所有变量都含有与原来的对象相同的值,而所有的对其他对象的引用仍然指向原来的对象.浅复制仅仅复制所考虑的对象,而 ...
- Codeforces Round #518 Div. 1没翻车记
A:设f[i][j][0/1]为前i个数第i位为j且第i位未满足/已满足限制的方案数.大力dp前缀和优化即可. #include<iostream> #include<cstdio& ...
- poj 1034 The dog task (二分匹配)
The dog task Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2559 Accepted: 1038 Sp ...
- 【C++ troubleshooting】A case about decltype
template <typename iter_t> bool next_permutation(iter_t beg, iter_t end) { // if (beg == end | ...
- 【题解】AHOI2009同类分布
好开心呀~果然只有不看题解做出来的题目才会真正的有一种骄傲与满足吧ヾ(๑╹◡╹)ノ" 实际上这题只要顺藤摸瓜就可以了.首先按照数位dp的套路,有两维想必是省不掉:1.当前dp到到的位数:2. ...
- BZOJ 3545 / 洛谷 P4197 Peaks 解题报告
P4197 Peaks 题目描述 在\(\text{Bytemountains}\)有\(N\)座山峰,每座山峰有他的高度\(h_i\).有些山峰之间有双向道路相连,共\(M\)条路径,每条路径有一个 ...
- BZOJ 4318: OSU! 期望概率dp && 【BZOJ3450】【Tyvj1952】Easy 概率DP
这两道题是一样的...... 我就说一下较难的那个 OSU!: 这道15行的水题我竟然做了两节课...... 若是f[i][0]=(1-p)*f[i-1][0]+(1-p)*f[i-1][1],f[i ...
- 解决echarts中X轴文字过长的问题。【转】
axisLabel: { interval: , formatter:function(value) { debugger var ret = "";//拼接加\n返回的类目项 ; ...
- E. Intercity Travelling
E. Intercity Travelling time limit per test 1.5 seconds memory limit per test 256 megabytes input st ...