1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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");
}
}
|