about summary refs log tree commit diff
path: root/others/easy20160714/09.c
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2017-01-01 21:05:53 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2017-01-01 21:15:44 +0700
commit7206ecee7579a10dd347d06b397b3790e969f8f3 (patch)
tree0b7218b75d8dae913fd91c695e105fc6f2256479 /others/easy20160714/09.c
parentc67182c04491f2cf8b67e78b68aebf32aea25470 (diff)
downloadcp-7206ecee7579a10dd347d06b397b3790e969f8f3.tar.gz
Add others/easy20160714
Diffstat (limited to 'others/easy20160714/09.c')
-rw-r--r--others/easy20160714/09.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/others/easy20160714/09.c b/others/easy20160714/09.c
new file mode 100644
index 0000000..b7f4b40
--- /dev/null
+++ b/others/easy20160714/09.c
@@ -0,0 +1,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;
+}