AI工具人
提示词工程师

codeforces 340 A. The Wall


水水的一道题,只需要找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;
}


赞(0) 打赏
未经允许不得转载:XINDOO » codeforces 340 A. The Wall

评论 抢沙发

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册