about summary refs log tree commit diff
path: root/10/CSP-KT2
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2016-10-08 09:56:43 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2016-10-08 09:56:43 +0700
commit2a7bc10f6c011d19fb3b0e73068f7e1a9c30ace0 (patch)
tree95190a32ec1c7098494849eea5a5ba6b53289585 /10/CSP-KT2
parent207cc2ae9893b0cdecd20119b9ede37f73cd4a1e (diff)
downloadcp-2a7bc10f6c011d19fb3b0e73068f7e1a9c30ace0.tar.gz
Initial commit
Diffstat (limited to '10/CSP-KT2')
-rw-r--r--10/CSP-KT2/DeThiLan2.pdfbin0 -> 818820 bytes
-rw-r--r--10/CSP-KT2/dcount.c27
-rw-r--r--10/CSP-KT2/hamming.c27
-rw-r--r--10/CSP-KT2/negpairs.c24
-rw-r--r--10/CSP-KT2/sumarv.c19
-rw-r--r--10/CSP-KT2/zpairs.c28
6 files changed, 125 insertions, 0 deletions
diff --git a/10/CSP-KT2/DeThiLan2.pdf b/10/CSP-KT2/DeThiLan2.pdf
new file mode 100644
index 0000000..6940278
--- /dev/null
+++ b/10/CSP-KT2/DeThiLan2.pdf
Binary files differdiff --git a/10/CSP-KT2/dcount.c b/10/CSP-KT2/dcount.c
new file mode 100644
index 0000000..e851210
--- /dev/null
+++ b/10/CSP-KT2/dcount.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+/* More than 8MB is used by this program, for *efficiency*. */
+
+int main()
+{
+	long n, i, a0, m = 0, max = 0;
+	long a[100001] = {}, b[100001];
+
+	scanf("%ld", &n);
+	for (i = 0; i < n; i++) {
+		scanf("%ld", &a0);
+		if (!a[a0]) {
+			b[m] = a0;
+			m++;
+		}
+		a[a0]++;
+	}
+
+	for (i = 0; i < m; i++)
+		if (a[b[i]] > max)
+			max = a[b[i]];
+
+	printf("%ld %ld\n", m, max);
+
+	return 0;
+}
diff --git a/10/CSP-KT2/hamming.c b/10/CSP-KT2/hamming.c
new file mode 100644
index 0000000..645eb17
--- /dev/null
+++ b/10/CSP-KT2/hamming.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+char *hamming(long m)
+{
+	while (m % 5 == 0)
+		m /= 5;
+	while (m % 3 == 0)
+		m /= 3;
+	while (m % 2 == 0)
+		m /= 2;
+	return (m > 1) ? "NO" : "YES";
+}
+
+int main()
+{
+	short n, i;
+	long a[10000];
+
+	scanf("%hd", &n);
+	for (i = 0; i < n; i++)
+		scanf("%ld", &a[i]);
+
+	for (i = 0; i < n; i++)
+		printf("%s\n", hamming(a[i]));
+
+	return 0;
+}
diff --git a/10/CSP-KT2/negpairs.c b/10/CSP-KT2/negpairs.c
new file mode 100644
index 0000000..577fdf8
--- /dev/null
+++ b/10/CSP-KT2/negpairs.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+int main()
+{
+	long n, i;
+	long unsigned_a[201] = {};
+	long *a = &unsigned_a[100];
+	char a0;
+	long long v;
+
+	scanf("%ld", &n);
+	for (i = 0; i < n; i++) {
+		scanf("%hhd", &a0);
+		a[a0]++;
+	}
+
+	v = a[0] * (a[0] - 1) / 2;
+	for (i = 1; i <= 100; i++)
+		v += a[i] * a[-i];
+
+	printf("%lld\n", v);
+
+	return 0;
+}
diff --git a/10/CSP-KT2/sumarv.c b/10/CSP-KT2/sumarv.c
new file mode 100644
index 0000000..3e5bc7e
--- /dev/null
+++ b/10/CSP-KT2/sumarv.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+
+int main()
+{
+	short n, i;
+	long b[10001] = {};
+
+	scanf("%hd", &n);
+	for (i = 1; i <= n; i++) {
+		scanf("%ld", &b[i]);
+		b[i] *= i;
+	}
+
+	for (i = 1; i <= n; i++)
+		printf("%ld ", b[i] - b[i - 1]);
+	printf("\n");
+
+	return 0;
+}
diff --git a/10/CSP-KT2/zpairs.c b/10/CSP-KT2/zpairs.c
new file mode 100644
index 0000000..d0d6186
--- /dev/null
+++ b/10/CSP-KT2/zpairs.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+
+int main()
+{
+	short m, n, i, j, v = 0;
+	long a[10000], b;
+
+	scanf("%hd %hd", &n, &m);
+	for (i = 0; i < n; i++)
+		scanf("%ld", &a[i]);
+
+	i = 0;
+	for (j = 0; j < m; j++) {
+		if (i >= n)
+			break;
+		scanf("%ld", &b);
+		while (b > a[i])
+			i++;
+		if (b == a[i]) {
+			v++;
+			i++;
+		}
+	}
+
+	printf("%hd\n", v);
+
+	return 0;
+}