• URAL 1779 F


    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
    ",ans[i].x,ans[i].y);
        }
        return 0;
    }
  • 相关阅读:
    夯实Java基础(六)——包装类
    JavaWeb:Cookie
    JavaWeb:HttpServletResponse
    JavaWeb:ServletResponse
    JavaWeb:HttpServletRequest
    JavaWeb:ServletRequest(二)
    JavaWeb:ServletRequest(一)
    JavaWeb:HttpServlet
    JavaWeb:GenericServlet
    Spring:Spring Cloud 2020 年维护路线图
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4728608.html
Copyright © 2020-2023  润新知