代码:
1 #include <fstream> 2 #include <iostream> 3 #include <algorithm> 4 #include <cstdio> 5 #include <cstring> 6 #include <cmath> 7 #include <cstdlib> 8 9 using namespace std; 10 11 #define PI acos(-1.0) 12 #define EPS 1e-10 13 #define lll __int64 14 #define ll long long 15 #define INF 0x7fffffff 16 17 const int N=10005; 18 int du[N]; 19 20 int main(){ 21 //freopen("D:\input.in","r",stdin); 22 //freopen("D:\output.out","w",stdout); 23 int n,m,t1,t2; 24 scanf("%d %d",&n,&m); 25 for(int i=0;i<m;i++){ 26 scanf("%d %d",&t1,&t2); 27 du[t1]++,du[t2]++; 28 } 29 ll ans=0; 30 for(int i=1;i<=n;i++) ans+=(ll)du[i]*du[i]; 31 printf("%lld ",ans); 32 return 0; 33 }