http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1316
水!!!
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int N=200005;
const ll MOD = 1000000007;
ll a[N];
int main()
{
//freopen("data.in","r",stdin);
int T;
cin>>T;
while(T--)
{
int n,m;
cin>>n>>m;
memset(a,0,sizeof(a));
for(int i=1;i<=m;++i)
{
int l,r;
cin>>l>>r;
++a[l];++a[r];
}
ll ans=0;
for(int i=1;i<=n;++i)
{//cout<<a[i]<<endl;
ans+=(a[i]*a[i]);
}
cout<<ans<<endl;
if(T>0)cout<<endl;
}
return 0;
}