• Tournament ZOJ


    打表题。。

    规律是找出来了 奈何优化不了 。。。。

    #include <iostream>
    #include <cstdio>
    #include <sstream>
    #include <cstring>
    #include <map>
    #include <cctype>
    #include <set>
    #include <vector>
    #include <stack>
    #include <queue>
    #include <algorithm>
    #include <cmath>
    #include <bitset>
    #define rap(i, a, n) for(int i=a; i<=n; i++)
    #define rep(i, a, n) for(int i=a; i<n; i++)
    #define lap(i, a, n) for(int i=n; i>=a; i--)
    #define lep(i, a, n) for(int i=n; i>a; i--)
    #define rd(a) scanf("%d", &a)
    #define rlld(a) scanf("%lld", &a)
    #define rc(a) scanf("%c", &a)
    #define rs(a) scanf("%s", a)
    #define rb(a) scanf("%lf", &a)
    #define rf(a) scanf("%f", &a)
    #define pd(a) printf("%d
    ", a)
    #define plld(a) printf("%lld
    ", a)
    #define pc(a) printf("%c
    ", a)
    #define ps(a) printf("%s
    ", a)
    #define MOD 2018
    #define LL long long
    #define ULL unsigned long long
    #define Pair pair<int, int>
    #define mem(a, b) memset(a, b, sizeof(a))
    #define _  ios_base::sync_with_stdio(0),cin.tie(0)
    //freopen("1.txt", "r", stdin);
    using namespace std;
    const int maxn = 1100, INF = 0x7fffffff, LL_INF = 0x7fffffffffffffff;
    int way[maxn][maxn];
    int sta[maxn];
    void solve()
    {
        way[1][1] = 1;
        for(int i = 2; i <= 1024; i *= 2)
        {
            int k = i >> 1;
            for(int x = 1; x <= k; x++)
                for(int y = 1; y <= k; y++)
                {
                    way[x + k][y + k] = way[x][y];
                    way[x + k][y] = way[x][y + k] = way[x][y] + k;
                }
        }
    }
    
    int main()
    {
        int T, n, k;
        solve();
        cin >> T;
        while(T--)
        {
            int cnt = 0;
            cin >> n >> k;
    //        if((n & 1) || !(n & 1) && k > n - 1)
    //        {
    //            cout << "Impossible" << endl;
    //            continue;
    //        }
            for (int i = 2; i <= n; i++)
            {
                bool flag = 0;
                for (int j = 1; j <= n; j++)
                {
                    if(way[i][j] > n)
                    {
                        flag = 1; break;
                    }
                }
                if(!flag) sta[cnt++] = i;
            }
            if(cnt < k)
            {
                cout << "Impossible" << endl;
                continue;
            }
            for(int i = 0; i < k; i++)
                for(int j = 1; j <= n; j++)
                    printf("%d%s", way[sta[i]][j], (j == n ? "
    " : " "));
    
        }
    
        return 0;
    }
    自己选择的路,跪着也要走完。朋友们,虽然这个世界日益浮躁起来,只要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也能够保持自己的本色走下去。
  • 相关阅读:
    Linux zip打包排除某个目录或只打包某个目录
    解决coreseek及sphinx查询结果不全--匹配参数详解
    curl错误28:Resolving timed out after 15009 milliseconds解决方案
    PHP实现关键词全文搜索Sphinx及中文分词Coreseek的安装配置
    Nginx指定多个域名跨域配置
    PHP友盟推送消息踩坑及处理
    Redis批量删除的方法
    Redis数据类型及常用方法整理
    PHPExcel导入导出常用方法总结
    [633] 平方数之和
  • 原文地址:https://www.cnblogs.com/WTSRUVF/p/9935312.html
Copyright © 2020-2023  润新知