Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
要崩溃了,为什么是WA?#include<stdio.h> #define SIZE 1000 typedef struct { int x,y; int number; }NNN; int n[SIZE]; int m[SIZE]={2}; int Count() { int i,j; int num=0; for(i=3;i<SIZE;i+=2) { if(n[i]==0) m[++num]=i; for(j=1;j<=num&&i*m[j]<=SIZE;j++) n[i*m[j]]=1; } return num; } int main() { int a,b,c; int i,j,k; int num; NNN stat[SIZE]; int max; num=Count(); while(scanf("%d%d%d",&a,&b,&c)==3) { if(a==0&&b==0&&c==0) break; k=0; for(i=num;i>=0;i--) { for(j=i;j>=0;j--) { if((double)m[j]/m[i]>=(double)b/c&&m[j]*m[i]<=a) { stat[k].x=m[j]; stat[k].y=m[i]; stat[k].number=m[i]*m[j]; k++; break; } } } max=0; for(i=1;i<k;i++) if(stat[max].number<stat[i].number) max=i; printf("%d %d\n",stat[max].x,stat[max].y); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator