URAL 1779 F - The Great Team 构造
2015-08-13 22:16
281 查看
[b]F - The Great Team[/b]
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87643#problem/F
Description
When a few students of the Ural State University finished their sport career, the university encountered a lot of problems in team composition. Veterans of sports programming decided to play their role and create the most successful team in the history of the Ural SU.
Veterans assumed that success of a team strongly depends on the number of friends in the ACM community the members of this team have. After more discussions they developed the criterion of success: all three members of the team should have the same number of friends.
Unfortunately, the veterans failed to compose a team, as it turned out that there were no three programmers in the Ural SU that together satisfied this criterion.
You should use this information to determine which students are friends of each other.
Input
The first line contains a single integer n (3 ≤ n ≤ 200) , which is the number of students in the Ural SU participating in programming contests.
Output
If the veterans' calculations are correct, the first line should contain an integer k, which is the number of pairs of students that are friends of each other. The following k lines should contain these pairs. Students should be numbered 1 through n. If a problem has multiple correct answers, output any of them.
If the veterans are wrong and the problem has no solution, output a single line containing a number −1.
Sample Input
4
Sample Output
2
1 3
3 4
HINT
题意
有n个点,然后让你构造一个图,使得每种度数的点,都不超过3个
题解:
每个点,都从i一直连到n-i+1就好了
代码:
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87643#problem/F
Description
When a few students of the Ural State University finished their sport career, the university encountered a lot of problems in team composition. Veterans of sports programming decided to play their role and create the most successful team in the history of the Ural SU.
Veterans assumed that success of a team strongly depends on the number of friends in the ACM community the members of this team have. After more discussions they developed the criterion of success: all three members of the team should have the same number of friends.
Unfortunately, the veterans failed to compose a team, as it turned out that there were no three programmers in the Ural SU that together satisfied this criterion.
You should use this information to determine which students are friends of each other.
Input
The first line contains a single integer n (3 ≤ n ≤ 200) , which is the number of students in the Ural SU participating in programming contests.
Output
If the veterans' calculations are correct, the first line should contain an integer k, which is the number of pairs of students that are friends of each other. The following k lines should contain these pairs. Students should be numbered 1 through n. If a problem has multiple correct answers, output any of them.
If the veterans are wrong and the problem has no solution, output a single line containing a number −1.
Sample Input
4
Sample Output
2
1 3
3 4
HINT
题意
有n个点,然后让你构造一个图,使得每种度数的点,都不超过3个
题解:
每个点,都从i一直连到n-i+1就好了
代码:
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <cmath> #include <vector> #include <stack> #include <map> #include <set> #include <queue> #include <iomanip> #include <string> #include <ctime> #include <list> #include <bitset> typedef unsigned char byte; #define pb push_back #define input_fast std::ios::sync_with_stdio(false);std::cin.tie(0) #define local freopen("in.txt","r",stdin) #define pi acos(-1) using namespace std; const int maxn = 200 + 50; int n; int degree[maxn]; struct node { int x,y; }; vector<node> ans; int main(int argc,char *argv[]) { cin>>n; for(int i=1;i<=n;i++) { for(int j=i+1;j<=n-i+1;j++) { node k; k.x=i,k.y=j; ans.push_back(k); } } cout<<ans.size()<<endl; for(int i=0;i<ans.size();i++) { printf("%d %d\n",ans[i].x,ans[i].y); } return 0; }
相关文章推荐
- (大数据工程师学习路径)第三步 Git Community Book----基本用法(下)
- [我们是这样理解语言的-3]神经网络语言模型(续)
- HDU 4265(Science!-二分网络流)
- FQA 之线程相关
- HTTP 方法:GET 对比 POST 转自w3school
- 系统架构师考试——程序计数器 PC, 指令寄存器IR、状态寄存器SR、通用寄存器GR
- coj 1342: Double
- 【Effective C++ 3rd 心得、归纳、实践】 Item 12: 拷贝一个对象的所有组成部分
- LNAMP源码安装整合加论坛及动静分离
- [我们是这样理解语言的-3]神经网络语言模型
- networkx笔记:绘制基本网络图
- 动态规划——F 最大矩阵和
- OC_id类型
- JAVA基础一大堆0813Web项目
- ptmalloc
- onfocus事件
- HDU 1542 Atlantis (线段树 + 扫描线 + 离散化)
- [我们是这样理解语言的-2]统计语言模型
- uvalive 4329
- LeetCode - Course Schedule 解题报告