【HDOJ】1239 Calling Extraterrestrial Intelligence Again
这题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的更多相关文章
- hdu 1239 Calling Extraterrestrial Intelligence Again (暴力枚举)
Calling Extraterrestrial Intelligence Again Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- poj 1411 Calling Extraterrestrial Intelligence Again(超时)
Calling Extraterrestrial Intelligence Again Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
- HDUOJ-----(1329)Calling Extraterrestrial Intelligence Again
Calling Extraterrestrial Intelligence Again Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- 【AI】Computing Machinery and Intelligence - 计算机器与智能
[论文标题] Computing Machinery and Intelligence (1950) [论文作者] A. M. Turing (Alan Mathison Turing) [论文链接] ...
- 【51nod】1239 欧拉函数之和 杜教筛
[题意]给定n,求Σφ(i),n<=10^10. [算法]杜教筛 [题解] 定义$s(n)=\sum_{i=1}^{n}\varphi(i)$ 杜教筛$\sum_{i=1}^{n}(\varph ...
- 【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,二分出对应 ...
- 【HDOJ】4729 An Easy Problem for Elfness
其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...
- 【HDOJ】【2829】Lawrence
DP/四边形不等式 做过POJ 1739 邮局那道题后就很容易写出动规方程: dp[i][j]=min{dp[i-1][k]+w[k+1][j]}(表示前 j 个点分成 i 块的最小代价) $w(l, ...
- 【HDOJ】【3506】Monkey Party
DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cst ...
随机推荐
- mark jquery 链式调用的js原理
我们在使用jquery的时候会用到类似$("#id").css('color','red').show(200); 这样写有点减少代码量,减少了逐步查询DOM的性能损耗: js 原 ...
- PAT_1072 Gas Station
1072. Gas Station (30) 时间限制 200 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...
- Haproxy配置参数
HAProxy配置中分成五部分内容,当然这些组件不是必选的,可以根据需要选择部分作为配置. ===================== global 参数是进程级的,通常和操作系统(OS)相关. ...
- DailyNote
删除node-modules文件夹 npm install -g rimraf rimraf node_modules 绘制一条贝塞尔曲线: context.quadraticCurveTo(x1,y ...
- linux管道学习(一)
最近学习了管道 pipe,在这里进行一下总结. 这里贴一段自己的实做代码 struct node{ int a; long b; }; int main() { ]; pid_t pid; ]; in ...
- 绑定本地Service并与之通信
绑定Service需要调用 public boolean bindService (Intent service, ServiceConnection conn, int flags): 传入一个Se ...
- PHP CURL参数详解
curl用法:cookie及post 一.cookie用法 <?php $cookie_jar = tempnam('./tmp','cookie'); // login $c=curl_ini ...
- 利用Xlinix SDK 建立Linux程序以及对该程序进行调试
一.创建Linux程序 1. 点击File > New > Application Project .并参照下图设置. 2. 输入工程名,并选择存储路径. 3. 选择所需的操作系统平台(O ...
- 曾经的10道JAVA面试题
1.HashMap和Hashtable的区别. 都属于Map接口的类,实现了将惟一键映射到特定的值上.HashMap 类没有分类或者排序.它允许一个null 键和多个null 值.Hashtable ...
- BOM 子对象,history,location,screen
history:包括浏览器访问过的 url 属性:返回浏览器访问过的历史记录数 方法:back(); forward(); go(number) location:包含当前 url 的相关信息 属性: ...