⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1994.cpp

📁 这是哈尔滨工业大学acmOJ的源代码
💻 CPP
字号:
/*  This Code is Submitted by wywcgs for Problem 1994 on 2006-02-21 at 12:18:58 */ 
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAX = 1024;

int main()
{
	int t, T, i;
	int red[MAX];
	
	scanf("%d", &T);
	for(t = 0; t < T; t++) {
		int n, m, total = 0;
		scanf("%d %d", &n, &m);
		memset(red, 0, sizeof(red));
		for(i = 0; i < m; i++) {
			int a, b;
			scanf("%d %d", &a, &b);
			red[a-1]++; red[b-1]++;
		}
		for(i = 0; i < n; i++) total += red[i] * (n - 1 - red[i]);
		printf("%d\n", n*(n-1)*(n-2)/6-total/2);
	}
	
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -