Cod sursa(job #6873)
| Utilizator | Data | 21 ianuarie 2007 10:08:42 | |
|---|---|---|---|
| Problema | Triplete | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | preONI 2007, Runda 1, Clasa a 10-a | Marime | 0.63 kb |
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
long t[4097], x, y, i;
long long tot, n, m;
FILE *f;
int main()
{
f=fopen("triplete.in", "r");
fscanf(f, "%ld%ld\n", &n, &m);
memset(t, 0, sizeof(t));
for (i=0; i<m; ++i)
{
fscanf(f, "%ld%ld\n", &x, &y);
++t[x];
++t[y];
}
fclose(f);
f = fopen("triplete.out", "w");
tot = 0;
for (i=1; i<=n; ++i)
tot += t[i] * (n - t[i] - 1);
tot = ((n * (n - 1) * (n - 2)) / 3 - tot) / 2;
fprintf(f, "%lld", tot);
fclose(f);
return 0;
}
