这题wa了很多词,题目本身很简单,把a/b搞反了,半天才检查出来。

 #include <stdio.h>
#include <string.h>
#include <math.h> char isPrime[]; int main() {
int i, j, q, p, maxi, maxj, max;
double m, a, b, n, tmp1, tmp2; memset(isPrime, , sizeof(isPrime));
isPrime[] = isPrime[] = ;
for (i=; i<; ++i) {
if (isPrime[i]) {
for (j=i+i; j<; j+=i)
isPrime[j] = ;
}
} while (scanf("%lf %lf %lf", &m, &a, &b) != EOF) {
if (m==0.0f && a==0.0f && b==0.0f)
break;
n = a/b;
a = sqrt(m);
b = sqrt(m/n);
i = (int)floor(a);
j = (int)floor(b);
max = ;
for (p=j; p>=; --p) {
if ( !isPrime[p] )
continue;
if (p*i <= max)
break;
for (q=i; q>=; --q) {
if ( !isPrime[q] )
continue;
tmp1 = p*q;
tmp2 = q*1.0f/p;
if (tmp1<=m && tmp2<= && tmp2>=n) {
if (tmp1 > max) {
max = tmp1;
maxj = p;
maxi = q;
}
break;
}
}
}
printf("%d %d\n", maxi, maxj);
} return ;
}

【HDOJ】1239 Calling Extraterrestrial Intelligence Again的更多相关文章

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

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

  2. poj 1411 Calling Extraterrestrial Intelligence Again(超时)

    Calling Extraterrestrial Intelligence Again Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

  3. HDUOJ-----(1329)Calling Extraterrestrial Intelligence Again

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

  4. 【AI】Computing Machinery and Intelligence - 计算机器与智能

    [论文标题] Computing Machinery and Intelligence (1950) [论文作者] A. M. Turing (Alan Mathison Turing) [论文链接] ...

  5. 【51nod】1239 欧拉函数之和 杜教筛

    [题意]给定n,求Σφ(i),n<=10^10. [算法]杜教筛 [题解] 定义$s(n)=\sum_{i=1}^{n}\varphi(i)$ 杜教筛$\sum_{i=1}^{n}(\varph ...

  6. 【noi 2.7_413】Calling Extraterrestrial Intelligence Again(算法效率--线性筛素数+二分+测时)

    题意:给3个数M,A,B,求两个质数P,Q.使其满足P*Q<=M且A/B<=P/Q<=1,并使P*Q最大.输入若干行以0,0,0结尾. 解法:先线性筛出素数表,再枚举出P,二分出对应 ...

  7. 【HDOJ】4729 An Easy Problem for Elfness

    其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...

  8. 【HDOJ】【2829】Lawrence

    DP/四边形不等式 做过POJ 1739 邮局那道题后就很容易写出动规方程: dp[i][j]=min{dp[i-1][k]+w[k+1][j]}(表示前 j 个点分成 i 块的最小代价) $w(l, ...

  9. 【HDOJ】【3506】Monkey Party

    DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cst ...

随机推荐

  1. 一步一步学NUnit

    转载:http://tech.sina.com.cn/s/2009-07-17/1129988785.shtml 单元测试基础知识 单元测试是开发者编写的一小段代码,用于检验被测代码的一个很小的.很明 ...

  2. 使用ICSharpZipLib将文件夹压缩为zip文件

    序言:     在我接触Git和SVN之前,我最常用的保存数据的办法就是把文件夹压缩成一个zip文件,添加上时间戳.下面是我在学习C#的文件操作之后做的一个练习,使用开源的ICSharpZipLib来 ...

  3. WebSocket 实战

    http://www.ibm.com/developerworks/cn/java/j-lo-WebSocket/ 本文介绍了 HTML5 WebSocket 的由来,运作机制及客户端和服务端的 AP ...

  4. html-----009

    </head> <!-- 通过使用框架,你可以在同一个浏览器窗口中显示不止一个页面. <p> 垂直框架</p> 本例演示:如何使用三份不同的文档制作一个垂直框 ...

  5. java web-----DAO设计模式(数据库访问)

    一,DAO设计模式用于 j2ee 的数据层访问,包括五部分, 数据库连接类(包含数据库的连接与关闭操作的一个类), VO类(私有变量与数据库表格对应,接收数据库中表格各字段内容), DAO接口类(包含 ...

  6. UVA 11995 I Can Guess the Data Structure!(ADT)

    I Can Guess the Data Structure! There is a bag-like data structure, supporting two operations: 1 x T ...

  7. 为什么aspx这么“慢”

    首先你要明白什么viewstate:由系统生成的一个隐藏域,用来进行页面状态保持的 里面存放着关于判断页面是否提交的Ispostback,和一些关于服务器控件的状态和数据: (说明下 ,ViewSta ...

  8. O_NONBLOCK模式下写fifo的注意事项

    后台网络通信框架一般采用fifo来作为事件通知的机制:创建一个fifo,然后以非阻塞读和非阻塞写的方式打开fifo,然后把fd加到epoll里面,作为通知网络事件的fd. 在这里有个隐晦的问题容易被忽 ...

  9. 【CMD】findstr命令

    findstr用来搜索匹配字符串的文件. FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F:file] [ ...

  10. absolute之实现居中的三种方式

    居中思想可以由很多方式实现,这篇文章采用absolute实现:由传统方式开始到absolute独立使用方式 方式一:传统方式,父容器relateive,子元素absolute,然后left:50%,再 ...