Calling Extraterrestrial Intelligence Again Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11211   Accepted: 4356 Description A message from humans to extraterrestrial intelligence was sent through the Arecibo radio telescope in Puerto…
题意:给你数m,a,b,假设有数p,q,满足p*q<=m同时a/b<=p/q<=1,求当p*q最大的p和q的值 方法:暴力枚举 -_-|| and 优化范围 我们可以注意到在某一个m值得情况下,有一些小于m的值的质数根本不可能去到 以m=1680 a=5 b=16来举例,假设当前枚举的质数为x 那么既然选了这个x必然另外一个质数不可能小于x*5/16所以就可以得到一个方程 5/16*x^2<=1680 这样可以解出x=73.....(取整) #include <iostrea…
Calling Extraterrestrial Intelligence Again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3993    Accepted Submission(s): 2097 Problem Description A message from humans to extraterrestrial in…
Calling Extraterrestrial Intelligence Again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4083    Accepted Submission(s): 2140 Problem Description A message from humans to extraterrestrial in…
题目链接:http://poj.org/problem?id=1411 题目大意:找两个素数p,q满足a/b<=p/q<=1 且p*q<=m,求p*q最大的一组素数对. 第一次想的是筛素数,然后枚举,后来发现没有超时(汗,这让我们写正解的很GG). 正解是先筛素数,然后用mul数组对于两个素数的积存下较小的那个素数.最后从m向下枚举. 枚举代码: #include<cstdio> #include<cmath> #include<cstring> #i…
这题wa了很多词,题目本身很简单,把a/b搞反了,半天才检查出来. #include <stdio.h> #include <string.h> #include <math.h> ]; int main() { int i, j, q, p, maxi, maxj, max; double m, a, b, n, tmp1, tmp2; memset(isPrime, , sizeof(isPrime)); isPrime[] = isPrime[] = ; ; i&…
题意:给3个数M,A,B,求两个质数P,Q.使其满足P*Q<=M且A/B<=P/Q<=1,并使P*Q最大.输入若干行以0,0,0结尾. 解法:先线性筛出素数表,再枚举出P,二分出对应的最大的Q,得出最佳答案. 注意--1.第二个的代码是标准的欧拉筛,可求每个数的最小质因数:  2. 像第一个代码二分时通过位运算,使pri[]的下标尽量大来实现,比一般的二分快了很多很多!!一个6ms,一个502ms.具体请见代码. 1 #include<cstdio> 2 #include&l…
下面给出两道POJ上的问题,看如何用穷举法解决. [例9]Calling Extraterrestrial Intelligence Again(POJ 1411) Description A message from humans to extraterrestrial intelligence was sent through the Arecibo radio telescope in Puerto Rico on the afternoon of Saturday November 16…
#include<iostream> #include<stdio.h> #include<math.h> #define MAXN 50000 using namespace std; void give_list(); ] = {}; ; int main() { //freopen("acm.acm","r",stdin); int i; int j; double m; double a; double b; give_l…
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093. 1094.1095.1096.1097.1098.1106.1108.1157.116…