HDU 5750
来源:互联网 发布:网络宣传方案 编辑:程序博客网 时间:2024/06/06 01:43
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5750
Dertouzos
Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 871 Accepted Submission(s): 268
Problem Description
A positive proper divisor is a positive divisor of a number n , excluding n itself. For example, 1, 2, and 3 are positive proper divisors of 6, but 6 itself is not.
Peter has two positive integersn and d . He would like to know the number of integers below n whose maximum positive proper divisor is d .
Peter has two positive integers
Input
There are multiple test cases. The first line of input contains an integer T (1≤T≤106) , indicating the number of test cases. For each test case:
The first line contains two integersn and d (2≤n,d≤109) .
The first line contains two integers
Output
For each test case, output an integer denoting the answer.
Sample Input
910 210 310 410 510 610 710 810 9100 13
Sample Output
121000004
题意:给出t个n和d,让你求小于n的数中最大约数(不包括本身)为d的数量
题解:要使最大因数为d,必存在x*d=m,同时x必须为质数,且x必须小于d的最小质因数,因此找n前面有几个m即可
因为t范围很大,所以可以先筛选出质数表再线性扫一遍
恩,果然数论超级差系列
问题数论差就算了做题还有谜之自信这个方法肯定对...要检讨一下了
下面代码
#include<stdio.h>#include<string.h>#include<algorithm>#include<iostream>#include<stdlib.h>#include<math.h>#include<map>#include<vector>#include<set>#include<queue>using namespace std;int isprime[100005]={0};int primelist[100005]={0};int k=0;int prime(){int i,j;for(i=2;i<100000;i++){if(isprime[i]==0){for(j=2;i*j<100000;j++)isprime[i*j]=1;primelist[k]=i;k++;}}return 0;}int main(){int t,i;int m,n;scanf("%d",&t);prime();while(t--){cin>>m>>n;for(i=0;i<k;i++){if(n*primelist[i]>=m) break;if(n<primelist[i]) break;if(n%primelist[i]==0) break;}if(n*primelist[i]>=m || n<primelist[i]) i--;printf("%d\n",i+1);}return 0;}
0 0
- HDU 5750
- HDU 5750 Dertouzos
- hdu 5750 Dertouzos
- HDU-5750 Dertouzos
- hdu 5750 数学+预处理
- HDU 5750 Dertouzos
- HDU 5750 Dertouzos
- Hdu 5750 Dertouzos
- HDU 5750 Dertouzos
- HDU 5750 Dertouzos
- HDU 5750 Dertouzos(数论)
- HDU 5750 Dertouzos (数论)
- HDU 5750 Dertouzos
- hdu-5750-Dertouzos-数学
- HDU 5750 数学题
- HDU 5750 Dertouzos
- HDU 5750 Dertouzos(素数)
- hdu
- Android Shader渐变效果
- (OK) post - install-fedora.txt
- 尺取法应用积累
- java实现客户端与服务器通信
- 关于JAVA环境变量的配置问题
- HDU 5750
- 串行通信总述
- poj2403 模拟题目
- CodeForces 547B - Mike and Feet(单调栈)
- POJ 1703 Find them, Catch them .
- pandas append性能问题
- Bonita BPM Study
- java异常分类
- 内部类