URAL 1779 F - The Great Team 构造
F - The Great Team
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 = + ;
int n;
int degree[maxn];
struct node
{
int x,y;
};
vector<node> ans;
int main(int argc,char *argv[])
{
cin>>n;
for(int i=;i<=n;i++)
{
for(int j=i+;j<=n-i+;j++)
{
node k;
k.x=i,k.y=j;
ans.push_back(k);
}
}
cout<<ans.size()<<endl;
for(int i=;i<ans.size();i++)
{
printf("%d %d\n",ans[i].x,ans[i].y);
}
return ;
}
URAL 1779 F - The Great Team 构造的更多相关文章
- URAL 1549 Another Japanese Puzzle(构造)
题目大意 构造一条闭合路线,使得路线不能相交,并且走直线的步数小于等于 S,转弯(左转和右转)的步数小于等于 T.(0≤S,T≤1000) 求一条最长的路线 做法分析 注意到,因为要求路线闭合,那么转 ...
- Codeforces 410C.Team[构造]
C. Team time limit per test 1 second memory limit per test 256 megabytes input standard input output ...
- 牛客国庆集训派对Day2 F、平衡二叉树 【构造+记忆化搜索】
任意门:https://www.nowcoder.com/acm/contest/202/F 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 1048576K,其他语言2097152K6 ...
- Codeforces Round #598 (Div. 3) F. Equalizing Two Strings 构造
F. Equalizing Two Strings You are given two strings s and t both of length n and both consisting of ...
- 【Java 基础项目 - - Bank项目4】 对象构造/跨package调用
UML设计: 文件组织: (注: 在bank4中,直接调用bank3的内容, 不再重复编写代码即可!) 代码编写Bank.java: package Banking_4; import Banking ...
- django之 F与Q查询
F与Q查询 F查询 why?
- [C++11][算法][穷举]输出背包问题的所有可满足解
关于背包问题的题目,前人之述备矣,这里只讨论实现 输入: n ca w_1 v_1 w_2 v_2 ... w_n v_n 其中,n是物品总数,ca是背包大小,w_n是第n个物品的重量,v_n是第n个 ...
- Theos 工程
一.tweak 工程 1.创建步骤 a) terminal cd 到想要存放项目的目录下 b) 按图步骤完成即可 二.工程文件描述 1.control 记录 deb 包管理系统所需的基本信息. 2.a ...
- 计算bean的和(java)
bean中的属性过多时,要计算一个bean的list之和是一件非常麻烦的事情,可以用java的反射机制解决这件事情,代码如下: package com.jzzhcs.utils; import jav ...
随机推荐
- Oracle 课程六之hint
课程目标 完成本课程的学习后,您应该能够: •什么是oracle hint •Hint的使用范围 •Hint 汇总 •演示常用的hint Hint简介 Hint是oracle 提供的一种SQL语法 ...
- Java Error和Exception区别
Error和Exception都继承自Throwable: 二者不同之处: Exception: 1.可以是可被控制(checked)或者不可控制(unchecked): 2.表示一个由程序员导致的错 ...
- [HTML Q&A][转]使pre的内容自动换行
<pre> 元素可定义预格式化的文本.被包围在 pre 元素中的文本通常会保留空格和换行符.而文本也会呈现为等宽字体. <pre> 标签的一个常见应用就是用来表示计算机的源代码 ...
- Authentication with SignalR and OAuth Bearer Token
Authentication with SignalR and OAuth Bearer Token Authenticating connections to SignalR is not as e ...
- C++虚函数表原理
C++中的虚函数的作用主要是实现了多态的机制.关于多态,简而言之就是用父类型别的指针指 向其子类的实例,然后通过父类的指针调用实际子类的成员函数.这种技术可以让父类的指针有“多种形态”,这是一种泛型技 ...
- 通过实验分析system_call中断处理过程
作者:吴乐 山东师范大学 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 本实验目的:通过以一个简单的m ...
- 【随便走走】Vietnam
从来没有一个地方让我如此留念过. 初到越南印象就是乱,满街轰轰轰的摩托车,狭窄的街道,各种小酒店小商店.从机场出来的路上还看到了不少中国品牌如豪爵摩托等等. 落地办理了落地签,从大陆是不能办的.越 ...
- 02《老罗Android开发视频教程》第二集:android系统框架的介绍
- 教程-Close、Halt、terminate、ExitProcess的区别
Close:1.只关闭本窗体2.当Close是一个主窗体时,程序会退出.3.Close会发生FormClose事件,FormCloseQuery事件4.主窗体close以后程序就Application ...
- POJ 2502 Subway (最短路)
Subway 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/L Description You have just moved ...