about summary refs log tree commit diff
path: root/NTU/keba2.c
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-12-15 15:09:13 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-12-15 15:09:13 +0700
commit9e28e4c7b67c54229df11d355047ac8a88ea1817 (patch)
tree0d9d40db69613c2c49564a3f1987a005d61f4db3 /NTU/keba2.c
parent67393f42f41ab92219deb549f711121c4dab845b (diff)
downloadcp-9e28e4c7b67c54229df11d355047ac8a88ea1817.tar.gz
Normalize pathname
Diffstat (limited to 'NTU/keba2.c')
-rw-r--r--NTU/keba2.c49
1 files changed, 0 insertions, 49 deletions
diff --git a/NTU/keba2.c b/NTU/keba2.c
deleted file mode 100644
index d9316fd..0000000
--- a/NTU/keba2.c
+++ /dev/null
@@ -1,49 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-
-int cmp(const void *x, const void *y)
-{
-	return *(long long *) x - *(long long *) y;
-}
-
-int main()
-{
-	short n, i;
-	long b;
-	scanf("%hd %ld", &n, &b);
-	long long *s = malloc(n * 8);
-	for (i = 0; i < n; i++)
-		scanf("%lld", &s[i]);
-
-	qsort(s, n, 8, cmp);
-
-	short m = 0, hist[10000] = {1};
-	long long a[10000];
-	a[0] = s[0];
-	for (i = 1; i < n; i++) {
-		if (s[i] != a[m]) {
-			m++;
-			a[m] = s[i];
-		}
-		hist[m]++;
-	}
-	m++;
-
-	long val = 0;
-	long long foo;
-	void *p;
-	for (i = 0; i < m; i++) {
-		foo = b - a[i];
-		if (foo == a[i])
-			val += hist[i] * (hist[i] - 1) / 2;
-		if (foo <= a[i])
-			break;
-		p = bsearch(&foo, a, m, 8, cmp);
-		if (p != NULL)
-			val += hist[i] * hist[(long long *) p - a];
-	}
-
-	printf("%ld\n", val);
-
-	return 0;
-}