前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >codeforces 340 A. The Wall

codeforces 340 A. The Wall

作者头像
xindoo
发布2021-01-21 18:33:11
2900
发布2021-01-21 18:33:11
举报
文章被收录于专栏:XINDOO的专栏XINDOO的专栏

水水的一道题,只需要找xy的最小公倍数,然后找a b区间有多少个可以被xy的最小公倍数整除的数,就是答案。

代码语言:javascript
复制
//============================================================================
// 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;
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2013-08-31,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档