| ||||||||||
| 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 | |||||||||
超级暴力,居然超时了,哈哈!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator