codeforces 340 A. The Wall
2013-08-31 15:26
295 查看
水水的一道题,只需要找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
- CodeForces 690D1 The Wall (easy) (判断连通块的数量)
- CodeForces 340 C.Tourist Problem(组合数学)
- CodeForces 340 E.Iahub and Permutations(组合数学+dp)
- Codeforces_340A_The Wall(简单题)
- Codeforces-340A-The Wall
- CodeForces - 340 C - Tourist Problem
- CODEFORCES 340 XOR and Favorite Number 莫队模板题
- Codeforces 690D2 The Wall (medium)
- codeforces 690D2 D2. The Wall (medium)(组合数学)
- Codeforces-340-C(c++)
- Codeforces 340
- codeforces 340D D. Bubble Sort Graph(dp+线段树)
- CodeForces 690 D2.The Wall (medium)(组合数学)
- codeforces 372C Watching Fireworks is Fun 单调队列优化dp
- codeforces 601B (单调栈)
- CodeForces 166E--规律
- codeforces contest 349
- 【 codeforces 749C 】 Voting
- codeforces 894 E(scc + dp)