标签:style http color os io ar 数据 2014 div
给你三个数,n,m1,m2,找出所有小于n的能被m1或m2整除的数的个数。

12 2 3
7
代码:
#include<stdio.h>
int Gcd(int n,int m)
{
if(m==0)
return n;
else
return Gcd(m,n%m);
}
int main()
{
int n,m1,m2;
while(~scanf("%d%d%d",&n,&m1,&m2))
{
int x,k;
x=m1/Gcd(m1,m2)*m2;
printf("%d\n",(n-1)/m1+(n-1)/m2-(n-1)/x);
}
return 0;
}NYOJ-How many integers can you find
标签:style http color os io ar 数据 2014 div
原文地址:http://blog.csdn.net/qq_18062811/article/details/38896095