您的位置:首页 > 其它

codeforces 340 A. The Wall

2013-08-31 15:26 295 查看
水水的一道题,只需要找xy的最小公倍数,然后找a b区间有多少个可以被xy的最小公倍数整除的数,就是答案。

//============================================================================
// Name        : 2013083101.cpp
// Author      : xindoo
// Version     :
// Copyright   : Your copyright notice
// Description : codeforces 340A
//============================================================================

#include <iostream>
#include <stdio.h>

using namespace std;

int gcd (int a, int b) {
if (a % b == 0)
return b;
else
return gcd(b, a%b);
}

int main() {
int x, y, a, b;
while (scanf("%d %d %d %d", &x, &y, &a, &b) != EOF) {
int t = x*y/gcd(x, y);
int ans = b/t - a/t;
if (a%t == 0)
ans++;
cout << ans << endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: