blob: b7f4b407c2ff54a5f6bc1f3b77929bd599fe8c82 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <stdio.h>
long gcd(long x, long y)
{
long tmp;
while (y) {
tmp = x % y;
x = y;
y = tmp;
}
return x;
}
int main()
{
FILE *f = fopen("INP.TXT", "r");
long l, r, a;
short b;
fscanf(f, "%ld %ld %ld %hd", &l, &r, &a, &b);
fclose(f);
a = a * b / gcd(a, b);
l = (l % a) ? (l / a + 1) * a : l;
f = fopen("OUT.TXT", "w");
fprintf(f, "%ld\n", (r - l) / a + 1);
fclose(f);
return 0;
}
|