当前位置: 首页 > news >正文

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 = 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;
}

 

转载于:https://www.cnblogs.com/qscqesze/p/4728608.html

相关文章:

  • 如何应用混沌进行置乱
  • Ruby源文件指引
  • poj 2828 块状链表 OR 线段树 OR 树状数组
  • Ruby用6行搞定P2P
  • Bootstrap中面板的使用
  • LCA rmq st model
  • 一个有意思的Ruby脚本
  • 如何提醒客户重载父类的指定方法?
  • 将键盘的按键转换成相应的Unicode 值
  • sqlserver 锁表语句分享
  • 产品版本改造中的项目管理
  • 一种人吃蜂蜜火上浇油
  • windows 特殊文件后缀集合
  • 异或+构造 HDOJ 5416 CRB and Tree
  • 使用loader加载swf
  • [NodeJS] 关于Buffer
  • 07.Android之多媒体问题
  • Angular4 模板式表单用法以及验证
  • download使用浅析
  • ES6 学习笔记(一)let,const和解构赋值
  • ES6--对象的扩展
  • IndexedDB
  • Iterator 和 for...of 循环
  • Javascript编码规范
  • JAVA并发编程--1.基础概念
  • rabbitmq延迟消息示例
  • windows下mongoDB的环境配置
  • Zsh 开发指南(第十四篇 文件读写)
  • 和 || 运算
  • 基于webpack 的 vue 多页架构
  • 嵌入式文件系统
  • 通过npm或yarn自动生成vue组件
  • 终端用户监控:真实用户监控还是模拟监控?
  • 7行Python代码的人脸识别
  • ​LeetCode解法汇总307. 区域和检索 - 数组可修改
  • ​ssh免密码登录设置及问题总结
  • # 达梦数据库知识点
  • #laravel 通过手动安装依赖PHPExcel#
  • (AtCoder Beginner Contest 340) -- F - S = 1 -- 题解
  • (c语言版)滑动窗口 给定一个字符串,只包含字母和数字,按要求找出字符串中的最长(连续)子串的长度
  • (M)unity2D敌人的创建、人物属性设置,遇敌掉血
  • (附源码)ssm高校运动会管理系统 毕业设计 020419
  • (论文阅读30/100)Convolutional Pose Machines
  • (三分钟)速览传统边缘检测算子
  • (万字长文)Spring的核心知识尽揽其中
  • (已更新)关于Visual Studio 2019安装时VS installer无法下载文件,进度条为0,显示网络有问题的解决办法
  • (转) Face-Resources
  • ..回顾17,展望18
  • .NET Core实战项目之CMS 第一章 入门篇-开篇及总体规划
  • .NET Core引入性能分析引导优化
  • .NET 应用架构指导 V2 学习笔记(一) 软件架构的关键原则
  • .NET 中使用 TaskCompletionSource 作为线程同步互斥或异步操作的事件
  • .net(C#)中String.Format如何使用
  • .NET3.5下用Lambda简化跨线程访问窗体控件,避免繁复的delegate,Invoke(转)
  • .NetCore Flurl.Http 升级到4.0后 https 无法建立SSL连接