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

codeforces 340 A. The Wall的更多相关文章

  1. codeforces D. Painting The Wall

    http://codeforces.com/problemset/problem/399/D 题意:给出n和m,表示在一个n*n的平面上有n*n个方格,其中有m块已经涂色.现在随机选中一块进行涂色(如 ...

  2. codeforces 690D2 D2. The Wall (medium)(组合数学)

    题目链接: D2. The Wall (medium) time limit per test 2 seconds memory limit per test 256 megabytes input ...

  3. codeforces 690D1 D1. The Wall (easy)(dfs)

    题目链接: D1. The Wall (easy) time limit per test 0.5 seconds memory limit per test 256 megabytes input ...

  4. CodeForces - 340 C - Tourist Problem

    先上题目: A - Tourist Problem Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & ...

  5. CODEFORCES 340 XOR and Favorite Number 莫队模板题

    原来我直接学的是假的莫队 原题: Bob has a favorite number k and ai of length n. Now he asks you to answer m queries ...

  6. codeforces A. The Wall 解题报告

    题目链接:http://codeforces.com/problemset/problem/340/A 这道题目理解不难,就是在[a, b]区间内,找出同时能够被x和y整除的个数.第一次想当然的开了两 ...

  7. [Codeforces Round #340 (Div. 2)]

    [Codeforces Round #340 (Div. 2)] vp了一场cf..(打不了深夜的场啊!!) A.Elephant 水题,直接贪心,能用5步走5步. B.Chocolate 乘法原理计 ...

  8. CodeForces Round #527 (Div3) D2. Great Vova Wall (Version 2)

    http://codeforces.com/contest/1092/problem/D2 Vova's family is building the Great Vova Wall (named b ...

  9. CodeForces Round #527 (Div3) D1. Great Vova Wall (Version 1)

    http://codeforces.com/contest/1092/problem/D1 Vova's family is building the Great Vova Wall (named b ...

随机推荐

  1. spring 5.x 系列第4篇 —— spring AOP (代码配置方式)

    文章目录 一.说明 1.1 项目结构说明 1.2 依赖说明 二.spring aop 2.1 创建待切入接口及其实现类 2.2 创建自定义切面类 2.3 配置切面 2.4 测试切面 2.5 切面执行顺 ...

  2. 【搬家啦】2019年06月20日csdn难民来报道啦~

    原博地址:https://blog.csdn.net/the_fool_

  3. Git项目迁移

    代码项目迁移步骤 1.将原有项目重命名,old 2.新建一个项目,名字为原本的项目名称,new 3.使用特殊方式克隆代码 # old.git为原项目重命名后的git链接 git clone --mir ...

  4. 从零开始实现ASP.NET Core MVC的插件式开发(一) - 使用ApplicationPart动态加载控制器和视图

    标题:从零开始实现ASP.NET Core MVC的插件式开发(一) - 使用Application Part动态加载控制器和视图 作者:Lamond Lu 地址:http://www.cnblogs ...

  5. 曹工说Tomcat4:利用 Digester 手撸一个轻量的 Spring IOC容器

    一.前言 一共8个类,撸一个IOC容器.当然,我们是很轻量级的,但能够满足基本需求.想想典型的 Spring 项目,是不是就是各种Service/DAO/Controller,大家互相注入,就组装成了 ...

  6. HDU 1811:Rank of Tetris(并查集+拓扑排序)

    http://acm.hdu.edu.cn/showproblem.php?pid=1811 Rank of Tetris Problem Description   自从Lele开发了Rating系 ...

  7. POJ 2914:Minimum Cut(全局最小割Stoer-Wagner算法)

    http://poj.org/problem?id=2914 题意:给出n个点m条边,可能有重边,问全局的最小割是多少. 思路:一开始以为用最大流算法跑一下,然后就超时了.后来学习了一下这个算法,是个 ...

  8. DRF 视图

    目录 一.DRF中的Request 二.前戏: 关于面向对象的继承 三.初级版本 1. settings.py文件 -- 注册app 2. models.py文件 -- 创建表 3. admin.py ...

  9. 《Python 3.5从零开始学》笔记-第8章 面向对象编程

    前几章包括开启python之旅.列表和元组.字符串.字典.条件和循环等语句.函数等基本操作.主要对后面几章比较深入的内容记录笔记. 第8章 面向对象编程 8.3深入类 #!/usr/local/bin ...

  10. kuangbin专题 专题一 简单搜索 Pots POJ - 3414

    题目链接:https://vjudge.net/problem/POJ-3414 题意:给你两个杯子,分别容量为A(1),B(2)和一个C,C是需要经过下列操作,得到的一个升数.(1) FILL(i) ...