水水的一道题,只需要找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. VsCode 常用快捷键、debug菜单、debug插件

    常用快捷键emmet                   百度emmet即可知  Ctrl + P            转到文件Ctrl+鼠标左键不松手     预览代码Ctrl+鼠标左键松手    ...

  2. 给 Windows 的终端配置代理

    初衷 由于项目开发使用go,所以经常要用到go get,但是吧,terminal下根本没办法下载啊,经常下载三个小时包,写代码一个小时 迫于无奈,只好找个方式可以在terminal下使用ss cmd下 ...

  3. docker命令总结

    用 docker pull 拉取镜像 root@lishichao-virtual-machine:~# docker pull hello-world Using default tag: late ...

  4. JUnit-4.13使用报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误

    今天重新复习spring的时候,调用Junit架包来进行测试,进入其官网  https://junit.org/junit5/,点击右上角的Junit4进行查看 2.出现了的页面是这个样子 我把这个页 ...

  5. c# bool类型和int类型的互转

    项目过程中,会有model的一些属性字段为‘是’或‘否’ 数据库字段一半定义为int,值则是0或1 数据库model转实体类的时候,bool和int可以直接相互转换 false强转int 值就是0 t ...

  6. C++学习书籍推荐《Exceptional C++(英文)》下载

    百度云及其他网盘下载地址:点我 作者简介 Herb Sutter is the author of three highly acclaimed books, Exceptional C++ Styl ...

  7. Java项目案例之--封装的实例

    Java项目案例之---封装的实例 有一个专业类,有一个专业对象,专业名称:计算机科学与技术,专业编号:J001,专业年限:4,对年限添加约束,如果输入小于0,则默认为0,否则显示输入的值 有一个学生 ...

  8. 好用的在线画图工具processon

    ProcessOn是一款基于SaaS的前沿.高效线上作图工具,它将Visio.Xmind等专业作图工具搬到了"云端" 注册链接:https://www.processon.com/ ...

  9. (转)代码结构中Dao,Service,Controller,Util,Model是什么意思?

    作者:技能树IT修真院链接:https://www.zhihu.com/question/58410621/answer/623496434来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商 ...

  10. 上传文件不落地转Base64字符串

    1. 问题描述 因需调用第三方公司的图像识别接口,入参是:证件类型.图像类型.图片base64字符串,采用http+json格式调用. 本来采用的方式是:前端对图片做base64处理,后端组装下直接调 ...