📄 1357.cpp
字号:
/* This Code is Submitted by wywcgs for Problem 1357 on 2006-01-12 at 03:06:45 */
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const int MAX = 10240;
const int LIMIT = 102400;
const double eps = 1e-4;
int main()
{
int p[MAX], pn = 0;
bool prime[LIMIT];
int i, j;
int m, a, b;
memset(prime, true, sizeof(prime));
for(i = 2; i < LIMIT; i++)
if(prime[i]) {
p[pn++] = i;
for(j = 2; i*j < LIMIT; j++) prime[i*j] = false;
}
while(scanf("%d %d %d", &m, &a, &b) != EOF && m != 0) {
int l = (int)(sqrt((double)m)+eps);
int d = upper_bound(p, p+pn, l) - p;
int w = 0, h = 0;
for(i = 0; i < d; i++) {
int u = min(p[i]*b/a, m/p[i]);
int uo = upper_bound(p, p+pn, u) - p - 1;
if(p[i]*p[uo] > w*h) w = p[i], h = p[uo];
}
printf("%d %d\n", w, h);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -