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 |
Re:打表过了这题,要怎么写代码才短,有一大牛才194BIn Reply To:打表过了这题,要怎么写代码才短,有一大牛才194B Posted by:fans at 2007-11-24 19:30:49 #include<stdio.h> #include<math.h> int prime(int n) { int i; for(i=2;i*i<=n;i++) if(n%i==0) return 0; return 1; } void main() { int m,a,b; int i,j,x,y; while(scanf("%d%d%d",&m,&a,&b),m) { y=0; while(m) { int k=(int)sqrt(m*a/b); if(k*k!=m) k+=1; j=(int)sqrt(m); for(i=k;i<=j;i++) if(m%i==0&&prime(i)&&prime(m/i)) {y=1;break;} if(y==1) break; m--; } printf("%d %d\n",i,m/i); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator