这题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 ;
}