标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4964 Accepted Submission(s): 2608
1 #include <stdio.h> 2 #include <string.h> 3 //const int INF = 100000 ; 4 double shu[100000] ; 5 int i, j, time, num[100000]; 6 void biao(int n) // 找到2~m 范围内所有素数 ; 7 { 8 memset(num, 0, sizeof(num)) ; 9 for(i=2; i<=n; i++) 10 { 11 if(num[i] == 0) 12 { 13 for(j=2*i; j<=n; j+=i) 14 { 15 num[j] = 1 ; 16 } 17 } 18 } 19 time = 0 ; 20 for(i=2; i<=n; i++) 21 { 22 if(num[i] == 0) 23 shu[time++] = i ; 24 } 25 } 26 int main() 27 { 28 int m, a, b ; 29 while(~scanf("%d %d %d", &m, &a, &b)) 30 { 31 if(m == 0 && a == 0 && b == 0) 32 break ; 33 double max = -1, q, p ; 34 double temp = a * 1.0 / b ; 35 36 biao(m) ; 37 38 for(i=time-1; i>=0; i--) // → 。 。← 据说很重要 ; 39 { 40 for(j=i; j<=time-1; j++) 41 { 42 if(shu[j]*shu[i] <= m && (shu[i]/shu[j] <= 1 && shu[i]/shu[j] >= temp )&& shu[i]* shu[j] > max) 43 { max = shu[i] * shu[j]; q = shu[i]; p = shu[j]; } 44 } 45 } 46 47 printf("%d %d\n", (int)q, (int)p) ; 48 } 49 return 0 ; 50 }
杭电1239--Calling Extraterrestrial Intelligence Again
标签:
原文地址:http://www.cnblogs.com/fengshun/p/4670776.html