Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:打表过了这题,要怎么写代码才短,有一大牛才194B

Posted by Pumbaa at 2008-06-23 20:57:19 on Problem 1411
In 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator