about summary refs log tree commit diff
path: root/others/easy20160714/25.c
diff options
context:
space:
mode:
Diffstat (limited to 'others/easy20160714/25.c')
-rw-r--r--others/easy20160714/25.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/others/easy20160714/25.c b/others/easy20160714/25.c
new file mode 100644
index 0000000..e01789c
--- /dev/null
+++ b/others/easy20160714/25.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main()
+{
+	FILE *f = fopen("INP.TXT", "r");
+	int n, k, *a, i, r = 1;
+
+	fscanf(f, "%d %d", &n, &k);
+	a = malloc(n * sizeof(int));
+
+	for (i = 0; i < n; i++)
+		fscanf(f, "%d", a + i);
+
+	fclose(f);
+
+	k = n / k;
+	for (i = k; i < n; i += k)
+		if (memcmp(a, a + i, k * sizeof(int))) {
+			r = 0;
+			break;
+		}
+
+	f = fopen("OUT.TXT", "w");
+	fputs(r ? "YES\n" : "NO\n", f);
+	fclose(f);
+
+	return 0;
+}