首先,p,q>=2,所以p,q<=50000;

然后,我们观察a<=b<1000,而p,q<=100000。那么,q>=10000时,p<=10,则a/b<=1/1000,这已是下限,所以,我们认为p,q<=10000;

 #include <iostream>
#include <cstdio> using namespace std; bool num[];
int m,a,b;
int pnum[]; int n;
void type_table(){
num[]=true;
for(int i=;i<=;i++){
if(!num[i]){
pnum[++n]=i;
for(int k=i+;k<=;k++){
if(num[k]) continue;
else if(k%i==) num[k]=true;
}
}
}
} int main(){
n=;
memset(num,false,sizeof(num));
type_table();
while(scanf("%d%d%d",&m,&a,&b)!=EOF){
if(m==&&a==&&b==) break;
int p=,q=; int ans=;
for(int i=n;i>=;i--){ //q
for(int k=;k<=i;k++){ //p
if(a*pnum[i]<=b*pnum[k]&&pnum[i]*pnum[k]<=m&&pnum[i]*pnum[k]>ans){
ans=pnum[i]*pnum[k];
p=pnum[k];q=pnum[i];
}
else if(pnum[i]*pnum[k]>m) break;
}
}
printf("%d %d\n",p,q);
}
return ;
}

hdu 1239的更多相关文章

  1. hdu 1239 Calling Extraterrestrial Intelligence Again (暴力枚举)

    Calling Extraterrestrial Intelligence Again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: ...

  2. [SinGuLaRiTy] 贪心题目复习

    [SinGuLaRiTy-1024] Copyright (c) SinGuLaRiTy 2017. All Rights Reserved. [POJ 2709] 颜料 (Painter) 题目描述 ...

  3. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  4. [转] HDU 题目分类

    转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...

  5. HDU ACM 题目分类

    模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...

  6. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  7. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  8. hdu 分类

    HDU分类 http://www.cnblogs.com/ACMan/archive/2012/05/26/2519550.html#2667329 努力A完.方便自己系统A题 不断更新中...... ...

  9. poj和hdu部分基础算法分类及难度排序

    最近想从头开始刷点基础些的题,正好有个网站有关于各大oj的题目分类(http://www.pythontip.com/acm/problemCategory),所以写了点脚本把hdu和poj的一些题目 ...

随机推荐

  1. Django 创建新项目后要完成的几个步骤

    首先,在过一遍创建新项目的步骤: -创建一个新项目 -建了数据库后要确定自己是用 mysql数据库  还是用 sqlite3数据库 -如果是mysql数据库,那一堆配置 -如果是sqlite3数据库, ...

  2. com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'admin' for key 'UK_dgxl7aijrr4hq8314exhw407s'

    严重: Servlet.service() for servlet [spring-mvc] in context with path [/learn] threw exception [Reques ...

  3. B - Is your horseshoe on the other hoof?

    Problem description Valera the Horse is going to the party with friends. He has been following the f ...

  4. A - Infinite Sequence

    Problem description Consider the infinite sequence of integers: 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2,  ...

  5. SQL连接其它服务器操作

    Exec sp_droplinkedsrvlogin ZYB,Null --删除映射(录与链接服务器上远程登录之间的映射) Exec sp_dropserver ZYB --删除远程服务器链接 EXE ...

  6. struts2拦截器(四)

    struts2拦截器原理: 当请求action时,struts2会查找配置文件,并根据配置实例化相对的 拦截器对象,然后串成一个列表,然后一个一个的调用列表中的拦截器. 比如:某些页面必须登录才可以访 ...

  7. border使用

    border属性 border-width  border-style  border-color  inherit border-style的值:none  dotted(点线)  dashed(虚 ...

  8. VmWare 安装 Centos

    VMware CentOS7 的 ISO 文件 方法/步骤   1 打开虚拟机软件“VMware”,选择“创建新的虚拟机”: 2 选择“自定义(高级)”选项,点击“下一步”: 3 在“硬件兼容性”处选 ...

  9. windows和linux无法访问VMware中linux的tomcat主页问题

    1.一定确定自己的tomcat服务器是启动的.(为了确保保险可以在测试前重新shutdown,startup一次) 2.确定自己访问的ip地址和端口号是正确的 如果是VMware外部windows的话 ...

  10. 【Linux】swap分区简介及空间增加方式

    swap分区简介 Swap分区在系统的物理内存不够用的时候,把硬盘空间中的一部分空间释放出来,以供当前运行的程序使用.那些被释放的空间可能来自一些很长时间没有什么操作的程序,这些被释放的空间被临时保存 ...