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;
    }
    
  • 相关阅读:
    数据库迁移至ASM
    获取数据库或SHEME的DDL语句
    membership配置数据库(SQL2000)
    DIV+CSS到底是什么?
    如何更改表的所有者权限
    windows server 2003 上“您要访问的网页有问题,无法显示。HTTP 500 内部服务器错误。”的问题解决方案!
    瞎忙
    瞎忙
    如何更改表的所有者权限
    DIV+CSS到底是什么?
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626864.html
Copyright © 2011-2022 走看看