The Great Team
2016-08-11 21:49
155 查看
The Great Team
.
.
题意:给n给点,要求你给出任意一种连接方案,使得没有三个点有同样的度数
.
.
解法:其实仔细思考很简单,从n=2开始递推,如果n为奇数就不作处理,n为偶数就与前面所有点连一条边。这样可以保证只有第一第二个点度数相同,如果来到奇数位置,多一个度数为0的点,到达偶数时前面所有点的度数加1,而偶数位置那个点的度数一定为当前最大值,所以这样递推没有任意三个点的度数相同。
.
.
#include <iostream> #include <stdio.h> #include <stdlib.h> using namespace std; int n, m, a[40000][2] = {0}; int main() { cin >> n; m = 1; a[1][0] = 1; a[1][1] = 2; for (int i = 3; i <= n; i++) { if (i%2 == 1) continue; for (int j = 1; j < i; j++) { m++; a[m][0] = i; a[m][1] = j; } } cout << m << endl; for (int i = 1; i <= m; i++) cout << a[i][0] << " " << a[i][1] << endl; }
相关文章推荐
- The Great Team(好题)
- ural 1779. The Great Team
- 简单图论 ural 1779. The Great Team
- URAL 1779. The Great Team
- URAL 1779 The Great Team 构造题
- 20140501 Anindilyakwa 题解&&The Great Team 题解
- URAL 1779 F - The Great Team 构造
- The Great Team(好题)
- 哈理工OJ 1248 The kth great number(优先队列求第k大数)
- HDU 4006 The kth great number(STL)
- [音乐]Pink Floyd - The Great gig of the sky
- 【HDU4006】The kth great number
- TF54000: Cannot update data because the server clock may have been set incorrectly. Contact your Team Foundation Server Administ
- UVa 10256 The Great Divide,判断两个凸包是否相离
- zoj 2321 Filling Out the Team
- Nunit--the TDD Great Tools.
- The 36th ACM/ICPC Asia Regional Dalian Site 1006 The kth great number
- hdu4006 The kth great number 优先队列
- The kth great number
- hdu 4006 The kth great number(优先队列)