这题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. Nullable类型和HashSet<T>集合

    今天接触到两个新的类型,查了一下才发现它们已经出现好久了,特作一下标记 Nullable结构 在System命名空间下,在 .NET Framework 2.0 版中是新增的:用它定义的值类型的对象与 ...

  2. Android Animation 动画属性

    在 Android 中, Animation 动画效果的实现可以通过两种方式进行实现: 一种是 tweened animation 渐变动画,另一种是 frame by frame animation ...

  3. 那天有个小孩跟我说LINQ(四)转载

    1  LINQ TO SQL(代码下载)       我们以一个酒店管理系统的数据库为例子         表结构很简单:GuestInfo(客人信息表),Room(房间表),RoomType(房间类 ...

  4. 冒泡排序算法(C#实现)

    简单的冒泡排序算法,代码如下: ] = temp; hasExchangeAction =true; //发生过互换 } } if (!hasExchangeAction) //如果没有发生过互换,则 ...

  5. 浅谈c#接口的问题,适合新手来了解

    这段时间的项目有用到接口,开始不是特别理解接口,只是单单知道接口定义非常简单,甚至觉得这个接口只是多此一举(个人开发的时候).现在开始团队开发,才发现接口原来是这么的重要和便捷! 接下来就来谈谈我这段 ...

  6. #添加屏蔽IP LINUX

    netfilter/iptables 的最大优点是它可以配置有状态的防火墙,这是 ipfwadm 和 ipchains 等以前的工具都无法提供的一种重要功能.有状态的防火墙能够指定并记住为发送或接收信 ...

  7. Oracle 10g 下载地址

    Oracle Database 10g Release 2 (10.2.0.1.0) Enterprise/Standard Edition for Microsoft Windows (32-bit ...

  8. leetcode problem (2-4)

    Problem 2 --- Add Two Numbers 简单的模拟题. Problem 3 --- Longest Substring Without Repeating Characters 题 ...

  9. BOM 子对象,history,location,screen

    history:包括浏览器访问过的 url 属性:返回浏览器访问过的历史记录数 方法:back(); forward(); go(number) location:包含当前 url 的相关信息 属性: ...

  10. 转:android中APK开机自动运行

    背景知识:当Android启动时,会发出一个系统广播,内容为ACTION_BOOT_COMPLETED,它的字符串常量表示为android.intent.action.BOOT_COMPLETED.只 ...