about summary refs log tree commit diff
path: root/others/other/quacau.c
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2017-07-11 22:33:40 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2017-07-11 22:33:40 +0700
commit1ceb9227cb48d50f57343fa42c32815b94855488 (patch)
tree94d34c4a7d679b7e23dec199f0fee8b224c2df7e /others/other/quacau.c
parent1f60c2ea7bf245486e104add6bafe5a34e0b83ae (diff)
downloadcp-1ceb9227cb48d50f57343fa42c32815b94855488.tar.gz
Add others/other/{chonso.py,divseq.c,hinhvuong.py,quacau.c}
Diffstat (limited to 'others/other/quacau.c')
-rw-r--r--others/other/quacau.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/others/other/quacau.c b/others/other/quacau.c
new file mode 100644
index 0000000..48abc03
--- /dev/null
+++ b/others/other/quacau.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main()
+{
+	FILE *f = fopen("quacau.inp", "r");
+	long n, m, i;
+	long long k, *ways;
+	char *broken;
+
+	fscanf(f, "%ld %ld %Ld", &n, &m, &k);
+	broken = calloc(n + 1, sizeof(char));
+	for (; k; k--) {
+		fscanf(f, "%ld", &i);
+		broken[i] = 1;
+	}
+	fclose(f);
+
+	ways = (long long *) calloc(n + m + 1, sizeof(long long)) + m;
+	*ways = 1;
+	for (i = 0; i < n; i++) {
+		k = (ways[i] + k - ways[i - m] + 1000000007) % 1000000007;
+		if (!broken[i + 1])
+			ways[i + 1] = k;
+	}
+
+	f = fopen("quacau.out", "w");
+	fprintf(f, "%Ld\n", ways[n]);
+	fclose(f);
+	return 0;
+}