The Great Team
来源:互联网 发布:阿里云存储 价格 编辑:程序博客网 时间:2024/03/29 18:29
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;}
0 0
- The Great Team
- URAL 1779. The Great Team
- The Great Team(好题)
- 20140501 Anindilyakwa 题解&&The Great Team 题解
- URAL 1779 The Great Team 构造题
- 简单图论 ural 1779. The Great Team
- URAL1779The Great Team
- What makes a great team
- The Great XOR (HackerRank the-great-xor)
- The Great St.Brmard
- FFMpeg,the Great.
- The Great Telecom Meltdown
- The kth great number
- The kth great number
- 10967 - The Great Escape
- The kth great number
- The kth great number
- The Great Gatsby
- java动态之反射机制relection
- spring 事务-使用@Transactional 注解(事务隔离级别)
- poj1328贪心
- hdu 4793
- iOS使用StoryBoard任意多个固定间距控件的摆放(转载)
- The Great Team
- 清除浮动的解决办法总结
- iOS常用三方库、插件、知名技术博客、常用开发工具使用介绍等等,大家可以一次性下载了!
- ios网络请求操作
- java的arraylist排序示例(arraylist用法)
- java设计模式_单一职责原则
- TCP拥塞避免
- 论为什么页面中要使用html,body {height: 100%;}
- POJ 3436 ACM Computer Factory