求最大公约数和最小公倍数

img


要求整数范围1到2的32次方,为什么我的AC率才10.83%

#include "stdio.h"
#include "conio.h"
main()
{
  int a,b,num1,num2,temp;
  printf("please input two numbers:\n");
  scanf("%d,%d",&num1,&num2);
  if(num1<num2)
  {
    temp=num1;
    num1=num2;
    num2=temp;
  }
  a=num1;b=num2;
  while(b!=0)/*利用辗除法,直到b为0为止*/
  {
    temp=a%b;
    a=b;
    b=temp;
  }
  printf("最大公约数:%d\n",a);
  printf("最小公倍数:%d\n",num1*num2/a);
  getch();
}