标签:
4 4 1 2 1 3 2 3 2 4
18
#include <cmath> #include <queue> #include <vector> #include <cstdio> #include <string> #include <cstring> #include <iomanip> #include <iostream> #include <algorithm> using namespace std; //#pragma comment(linker, "/STACK:1024000000,1024000000") #define FIN freopen("input.txt","r",stdin) #define FOUT freopen("output.txt","w",stdout) #define CASE(T) for(scanf("%d",&T);T--;) typedef long long LL; const int maxn = 10000 + 5; int N, M, cnt[maxn]; int main() { // FIN; int a, b; while(~scanf("%d %d", &N, &M)) { memset(cnt, 0, sizeof(cnt)); for(int i = 1; i <= M; i++) { scanf("%d %d", &a, &b); cnt[a]++, cnt[b]++; } LL ans = 0; for(int i = 1; i <= N; i++) { ans += (LL)(cnt[i] * (cnt[i] - 1) / 2); } ans *= 2; ans += 2 * M; printf("%lld\n", ans); } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
ACdream 1213 Matrix Multiplication【水题 、 找规律】
标签:
原文地址:http://blog.csdn.net/acmore_xiong/article/details/48000989