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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值