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 构造的更多相关文章

  1. URAL 1549 Another Japanese Puzzle(构造)

    题目大意 构造一条闭合路线,使得路线不能相交,并且走直线的步数小于等于 S,转弯(左转和右转)的步数小于等于 T.(0≤S,T≤1000) 求一条最长的路线 做法分析 注意到,因为要求路线闭合,那么转 ...

  2. Codeforces 410C.Team[构造]

    C. Team time limit per test 1 second memory limit per test 256 megabytes input standard input output ...

  3. 牛客国庆集训派对Day2 F、平衡二叉树 【构造+记忆化搜索】

    任意门:https://www.nowcoder.com/acm/contest/202/F 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 1048576K,其他语言2097152K6 ...

  4. 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 ...

  5. 【Java 基础项目 - - Bank项目4】 对象构造/跨package调用

    UML设计: 文件组织: (注: 在bank4中,直接调用bank3的内容, 不再重复编写代码即可!) 代码编写Bank.java: package Banking_4; import Banking ...

  6. django之 F与Q查询

    F与Q查询 F查询 why?

  7. [C++11][算法][穷举]输出背包问题的所有可满足解

    关于背包问题的题目,前人之述备矣,这里只讨论实现 输入: n ca w_1 v_1 w_2 v_2 ... w_n v_n 其中,n是物品总数,ca是背包大小,w_n是第n个物品的重量,v_n是第n个 ...

  8. Theos 工程

    一.tweak 工程 1.创建步骤 a) terminal cd 到想要存放项目的目录下 b) 按图步骤完成即可 二.工程文件描述 1.control 记录 deb 包管理系统所需的基本信息. 2.a ...

  9. 计算bean的和(java)

    bean中的属性过多时,要计算一个bean的list之和是一件非常麻烦的事情,可以用java的反射机制解决这件事情,代码如下: package com.jzzhcs.utils; import jav ...

随机推荐

  1. Delphi 函数参数修饰中的var 、out和const

      (1)var修饰符 添加var 是地址传递,会修改原有的变量 var s: string; begin S := 'Hello'; ChangeSVar(s); ShowMessage(S); e ...

  2. Centos6.5下编译安装ACE6.0

    ACE在Linux下的编译安装步骤(CentOS6.5 64Bit) Linux平台安装(CentOS6.5 64bit) 1, 下载ACE软件包,上传至Linux服务器(假设目录为/opt/ace, ...

  3. POJ 2456 Aggressive cows

    Aggressive cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11192   Accepted: 5492 ...

  4. [Everyday Mathematics]20150209

    设 $f$ 在区间 $I$ 上三阶可导, $f'\neq 0$, 则可定义 $f$ 的 Schwarz 导数: $$\bex S(f,x)=\frac{f'''(x)}{f'(x)}-\frac{3} ...

  5. excel 经验总结

    1.2007版excel表格中怎么将使用字母+数字下拉排序 比如:A201110300001怎么在excel表格中往下拉的时候变成A201110300002.A201110300003…… 方法: 因 ...

  6. Cake slicing

    题意: n*m的方格中有k个点,现在要把方格分开使得每个点在一个部分,每分一次花费边长的费用,求完成花的最小费用 分析: dp[sx][sy][ex][ey]表示分割起点(sx,sy)终点(ex,ey ...

  7. Ubuntu 12.04中文输入法的安装

    Ubuntu 12.04中文输入法的安装   Ubuntu上的输入法主要有小小输入平台(支持拼音/二笔/五笔等),Fcitx,Ibus,Scim等.其中Scim和Ibus是输入法框架. 在Ubuntu ...

  8. C++实现网格水印之调试笔记(三)—— 初有结果

    错误: error C2338: THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD 这种错误 ...

  9. My implementation of AVL tree

    C++实现的avl平衡树 #include <stdlib.h> #include <time.h> #include <string.h> #include &l ...

  10. matlab图像基础知识

    1.MATLAB支持的几种图像文件格式: ⑴JPEG(Joint Photogyaphic Expeyts Group):一种称为联合图像专家组的图像压缩格式. ⑵BMP(Windows Bitmap ...