zoukankan      html  css  js  c++  java
  • 【9707】循环比赛

    Time Limit: 1 second
    Memory Limit: 128 MB

    【问题描述】

    设有n个选手进行循环比赛,其中N=2^M,要求每名选手要与其他N-1名选手都赛一次,每名选手每天比赛一次,循环比赛共进行N-1天,
    要求每天没有选手轮空。
    【输入格式】

    M

    【输出格式】

    表格形式的比赛安排表(每个数场宽为3)

    Sample Input

    2

    Sample Output

    1 2 3 4
    2 1 4 3
    3 4 1 2
    4 3 2 1

    【题目链接】:http://noi.qz5z.com/viewtask.asp?id=9707

    【题解】

    最小4格,左上和右下,右上和左下对称;
    按照这个规则赋值整个表格就好;

    【完整代码】

    #include <cstdio>
    #include <cstdlib>
    #include <cmath>
    #include <set>
    #include <map>
    #include <iostream>
    #include <algorithm>
    #include <cstring>
    #include <queue>
    #include <vector>
    #include <stack>
    #include <string>
    using namespace std;
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define LL long long
    #define rep1(i,a,b) for (int i = a;i <= b;i++)
    #define rep2(i,a,b) for (int i = a;i >= b;i--)
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    
    typedef pair<int,int> pii;
    typedef pair<LL,LL> pll;
    
    void rel(LL &r)
    {
        r = 0;
        char t = getchar();
        while (!isdigit(t) && t!='-') t = getchar();
        LL sign = 1;
        if (t == '-')sign = -1;
        while (!isdigit(t)) t = getchar();
        while (isdigit(t)) r = r * 10 + t - '0', t = getchar();
        r = r*sign;
    }
    
    void rei(int &r)
    {
        r = 0;
        char t = getchar();
        while (!isdigit(t)&&t!='-') t = getchar();
        int sign = 1;
        if (t == '-')sign = -1;
        while (!isdigit(t)) t = getchar();
        while (isdigit(t)) r = r * 10 + t - '0', t = getchar();
        r = r*sign;
    }
    
    const int MAXN = 2e3;
    const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
    const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
    const double pi = acos(-1.0);
    
    int a[MAXN][MAXN];
    int m;
    
    int main()
    {
        //freopen("F:\rush.txt","r",stdin);
        scanf("%d",&m);
        int half = 1;
        a[1][1] = 1;
        rep1(k,1,m)
        {
            rep1(i,1,half)
                rep1(j,1,half)
                    a[i][j+half] = a[i][j]+half;
            rep1(i,1,half)
                rep1(j,1,half)
                    {
                        a[i+half][j+half] = a[i][j];
                        a[i+half][j] = a[i][j+half];
                    }
            half <<=1;
        }
        rep1(i,1,half)
            rep1(j,1,half)
                {
                    printf("%3d",a[i][j]);
                    if (j==half)
                        puts("");
                }
        return 0;
    }
    
  • 相关阅读:
    Quartz使用总结
    quartz基本介绍和使用
    Spring的StringUtils工具类
    JreBel热部署不生效,2019最新解决方法
    解决IDEA下SpringBoot启动没有Run Dashboard并找回
    IDEA十大经典常用插件
    Java8 Comparator 排序方法
    JRebel 激活码 2020
    比较两个java.util.Date 的日期(年月日)是否相同(忽略时、分、秒)的多种方法
    kafka的Lag 计算误区及正确方式
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626864.html
Copyright © 2011-2022 走看看