哈理工OJ1165---整除问题
#include<stdio.h>
int GCD(int a,int b)
{
int temp = b;
while (b)
{
temp = a%b;
a = b;
b = temp;
}
return a;
}
int LCM(int a,int b)
{
int temp_lcm;
temp_lcm=a*b/GCD(a,b); //最小公倍数等于两数之积除以最大公约数
return temp_lcm;
}
int main()
{
int N,a,b;
int arry[6];
int i;
int temp;
while ( EOF != scanf("%d%d%d",&N,&a,&b))
{
temp = 1;
for (i=0;i<N;i++)
{
scanf("%d",&arry[i]);
temp = LCM(temp,arry[i]);
}
printf("%d\n",b/temp-((a-1)/temp));
}
return 0;
}

浙公网安备 33010602011771号