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

超级暴力,居然超时了,哈哈!

Posted by Gara at 2010-07-28 11:27:56 on Problem 2429
#include<stdio.h>
int main()
{
	int a,b,i,j,k;
	while(1)
	{
		scanf("%d",&a);
		scanf("%d",&b);
 		for(i=1;i<b;i++)
			for(j=i;j<b;j++)
			{
				if(i*j==a*b&&(i%a==0&&j%a==0))
				{
					int m=(i<j)?i:j;
					int g;
					for(k=1;k<=m;k++)
					{
						if(i%k==0&&j%k==0)
							 g=k;
					}
					if(g==a)
						printf("%d %d\n",i,j);
				}
			}
	}
	return 0;
}

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