Cod sursa(job #211739)
Utilizator | Diaconeasa Andrei AndreiD | Data | 3 octombrie 2008 15:44:57 |
---|---|---|---|
Problema | Triplete | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.73 kb |
#include <stdio.h>
long long n,S;
long long t[4010];
int main()
{
freopen("triplete.in","rt",stdin);
scanf("%lld %lld\n", &n,&S);
long long i,x,y,j;
char ch[100];
for (i=1;i<=S;++i)
{
gets(ch);
x=y=j=0;
while(ch[j]!=' ')
{
x=x*10+ch[j]-'0';
j++;
}
j++;
while(ch[j])
{
y=y*10+ch[j]-'0';
j++;
}
t[x]++;
t[y]++;
}
for (i=1;i<=n;++i)
t[i]=n-1-t[i];
long long nr=0;
for (i=1;i<=n;++i)
nr=((n-1-t[i])*t[i])+nr;
freopen("triplete.out","wt",stdout);
printf("%lld", nr);
return 0;
}