summaryrefslogtreecommitdiffstats
path: root/inf/lige/1/3.c
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2022-11-18 19:10:40 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2022-11-18 19:10:40 +0100
commit775d3113cb90a3300eb2261842290f0884db420b (patch)
tree9181e6585cb6a0429ed736c6069f8c7f87f5cc19 /inf/lige/1/3.c
parentnekaj matematike (diff)
downloadsola-gimb-4-775d3113cb90a3300eb2261842290f0884db420b.tar
sola-gimb-4-775d3113cb90a3300eb2261842290f0884db420b.tar.gz
sola-gimb-4-775d3113cb90a3300eb2261842290f0884db420b.tar.bz2
sola-gimb-4-775d3113cb90a3300eb2261842290f0884db420b.tar.lz
sola-gimb-4-775d3113cb90a3300eb2261842290f0884db420b.tar.xz
sola-gimb-4-775d3113cb90a3300eb2261842290f0884db420b.tar.zst
sola-gimb-4-775d3113cb90a3300eb2261842290f0884db420b.zip
Diffstat (limited to 'inf/lige/1/3.c')
-rw-r--r--inf/lige/1/3.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/inf/lige/1/3.c b/inf/lige/1/3.c
new file mode 100644
index 0000000..ff62f33
--- /dev/null
+++ b/inf/lige/1/3.c
@@ -0,0 +1,52 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+int main (void) {
+ char buf[128];
+ fgets(buf, 128, stdin);
+ int p = atoi(buf);
+ int * c = calloc(10000, sizeof *c);
+ while (p--) {
+ fgets(buf, 128, stdin);
+ int n = atoi(buf);
+ int i = n;
+ int sum = 0;
+ while (i--) {
+ fgets(buf, 128, stdin);
+ c[i] = atoi(buf);
+ sum += c[i];
+ if (!c[i])
+ while (1);
+ }
+ long double avg = (long double) sum/n;
+#ifndef EVAL
+ fprintf(stderr, "primer %d ima %d števil, katerih avg je %Lf\n", p, n, avg);
+#endif
+ for (int i = 0; i < n-1; i++) {
+ if (c[i] == -1)
+ continue;
+ if (c[i] == avg)
+ continue;
+ for (int j = i+1; j < n; j++) {
+ if (c[j] == avg)
+ continue;
+ if (c[j] == -1)
+ continue;
+#ifndef EVAL
+ fprintf(stderr, "avg %d in %d je %Lf\n", c[i], c[j], (long double) (c[i]+c[j])/2);
+#endif
+ if ((long double) (c[i]+c[j])/2 == avg) {
+ c[i] = -1;
+ c[j] = -1;
+ break;
+ }
+ if (j == n-1)
+ goto bail;
+ }
+ }
+ printf("DA\n");
+ continue;
+bail:
+ printf("NE\n");
+ }
+}