zoukankan      html  css  js  c++  java
  • 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;
    }
    



  • 相关阅读:
    [JavaScript]编写一份会动的简历
    Vue.js 创建一个 CNODE 社区(1)
    hdu 2051
    hdu 2050
    hdu 2048
    赫夫曼编码
    R语言的学习(四)
    R语言的学习(三)
    R语言的学习(二)
    R语言的学习(一)
  • 原文地址:https://www.cnblogs.com/xindoo/p/3595044.html
Copyright © 2011-2022 走看看