Dertouzos

题意:

有中文,不说。

题解:

我看了别人的题解,还有个地方没懂, 为什么是 if(d%prime[i]==0) break; ?

代码:

#include <bits/stdc++.h>
using namespace std; const int INF=0x3f3f3f3f;
typedef long long ll;
#define PU puts("");
#define PI(A) printf("%d\n",A)
#define SI(N) scanf("%d",&(N))
#define SII(N,M) scanf("%d%d",&(N),&(M))
#define cle(a,val) memset(a,(val),sizeof(a))
#define rep(i,b) for(int i=0;i<(b);i++)
#define Rep(i,a,b) for(int i=(a);i<=(b);i++)
#define reRep(i,a,b) for(int i=(a);i>=(b);i--)
const double EPS= 1e-9 ; /* ///////////////////////// C o d i n g S p a c e ///////////////////////// */ const int MAXN= 40000 + 9 ; int prime[MAXN];
bool is_prime[MAXN];
int sieve(int n)
{
int p=0;
for (int i=0;i<=n;i++) is_prime[i]=true;
is_prime[0]=is_prime[1]=false;
for (int i=2;i<=n;i++){
if (is_prime[i]){
prime[p++]=i;
for (int j=2*i;j<=n;j+=i) is_prime[j]=false;
}
}
return p;
} int main()
{
int K=sieve(MAXN);
int T;
SI(T);
while(T--)
{
int n,d;
SII(n,d);
int ans=0;
for (int p=0;p<K;p++)
{
if (prime[p]*d>=n) break;
ans++;
if (d%prime[p]==0) break;
}
PI(ans);
}
return 0;
}

BestCoder HDU 5750 Dertouzos的更多相关文章

  1. hdu 5750 Dertouzos 素数

    Dertouzos Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  2. HDU 5750 Dertouzos

    Dertouzos Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  3. HDU 5750 Dertouzos 简单数学

    感悟:这又是zimpha巨出的一场题,然后04成功fst(也就是这题) 实际上还是too young,要努力增加姿势, 分析:直接枚举这些数不好枚举,换一个角度,枚举x*d,也就是d的另一个乘数是多少 ...

  4. 题解报告:hdu 5750 Dertouzos(最大真约数、最小素因子)

    Problem Description A positive proper divisor is a positive divisor of a number n, excluding n itsel ...

  5. bestcoder.hdu.edu.cn

    http://bestcoder.hdu.edu.cn/ Problem A 题目链接: http://bestcoder.hdu.edu.cn/contests/contest_showproble ...

  6. 【HDU 5750】Dertouzos(数学)

    题目给定n和d,都是10的9次方以内,求1到n里面有几个数最大因数是d?1000000组数据.解:求出d的满足p[i]*d<n的最小质因数是第几个质数.即为答案. #include<cst ...

  7. hud 5750 Dertouzos

    Dertouzos Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  8. hdu 5750(数论)

    Dertouzos Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  9. HDU 5682/BestCoder Round #83 1003 zxa and leaf 二分+树

    zxa and leaf Problem Description zxa have an unrooted tree with n nodes, including (n−1) undirected ...

随机推荐

  1. nginx的HA集群及配置

    一.服务器环境 master服务器: ip:192.168.11.155 系统环境:CentOS release 6.5 (Final) 内核版本:2.6.32-431.el6.x86_64 防火墙和 ...

  2. URAL-1989 Subpalindromes(单点更新+hash)

    题目大意:给一行字符串,两种操作:change(pos,char),将pos处字符改为char:isPalindrome(i,j),询问[i,j]之间是否为回文字符串. 题目分析:做正反两次字符串哈希 ...

  3. Redis server&Client executions

    https://www.nuget.org/packages/Microsoft.Extensions.Caching.Redis/ https://github.com/StackExchange/ ...

  4. SQLite在多线程环境下的应用

    文一 SQLite的FAQ里面已经专门说明,先贴出来.供以后像我目前的入门者学习. (7) 多个应用程序或者同一个应用程序的多个例程能同时存取同一个数据库文件吗? 多进程可以同时打开同一个数据库,也可 ...

  5. DNS与DSN

    dns是域名系统的缩写 dsn在一些专业书籍中是数据源的缩写

  6. python命令行添加Tab键自动补全

    1.编写一个tab的自动补全脚本,名为tab.py #!/usr/bin/python # python tab complete import sys import readline import ...

  7. 015. asp.net实现简易聊天室

    通过Application和Session来实现简单的聊天室和在线用户数统计 Global.asax代码: <%@ Application Language="C#" %&g ...

  8. 虚拟化之kvm与xen对比

    xen XenServer is the leading open source virtualization platform, powered by the Xen Project hypervi ...

  9. Undefined symbols for architecture i386: "MyGetOpenALAudioData(__CFURL const*, int*, int*, int*)"

    今天把apple developer上的例子程序oalTouch中的MyOpenALSupport.h和MyOpenALSupport.c添加到自己的工程中,并在另一个文件xxx.cpp里调用,结果出 ...

  10. 【转】SVN的UUID错误

    操作TortoiseSVN时,报如下错误:       Command Update       Repository UUID '62b86956-73d9-2945-ba87-0546d71898 ...