打表题。。

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

#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\n", a)
#define plld(a) printf("%lld\n", a)
#define pc(a) printf("%c\n", a)
#define ps(a) printf("%s\n", 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 = , INF = 0x7fffffff, LL_INF = 0x7fffffffffffffff;
int way[maxn][maxn];
int sta[maxn];
void solve()
{
way[][] = ;
for(int i = ; i <= ; i *= )
{
int k = i >> ;
for(int x = ; x <= k; x++)
for(int y = ; 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 = ;
cin >> n >> k;
// if((n & 1) || !(n & 1) && k > n - 1)
// {
// cout << "Impossible" << endl;
// continue;
// }
for (int i = ; i <= n; i++)
{
bool flag = ;
for (int j = ; j <= n; j++)
{
if(way[i][j] > n)
{
flag = ; break;
}
}
if(!flag) sta[cnt++] = i;
}
if(cnt < k)
{
cout << "Impossible" << endl;
continue;
}
for(int i = ; i < k; i++)
for(int j = ; j <= n; j++)
printf("%d%s", way[sta[i]][j], (j == n ? "\n" : " ")); } return ;
}

Tournament ZOJ - 4063 (青岛区域赛 F 打表)的更多相关文章

  1. 2016ACM青岛区域赛题解

    A.Relic Discovery_hdu5982 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Jav ...

  2. ACM/ICPC2016 青岛区域赛

    A(hdu5982).(模拟) 题意:输入n对数,将每对数相乘并相加 分析:模拟 B(hdu5983).(模拟) 题意:给你一个二阶魔方,问能否通过一次旋转使得给定魔方的每个面颜色相同 分析:模拟 C ...

  3. 2016 年 ACM/ICPC 青岛区域赛 Problem C Pocky

    昨晚乱入学弟的训练赛,想了一下这个题.推导的过程中,加深了对公理化的概率论理解.$\newcommand{\d}{\mathop{}\!\mathrm{d}}$ 解法一 考虑 $ d < L$ ...

  4. 2019icpc徐州区域赛F

    F. The Answer to the Ultimate Question of Life, The Universe, and Everything. 我的第一道真·打表题 这次是真的打表啊,不是 ...

  5. 2016青岛区域赛.Coding Contest(费用流 + 概率计算转换为加法计算)

    Coding Contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  6. HDU 4818 RP problem (高斯消元, 2013年长春区域赛F题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4818 深深地补一个坑~~~ 现场赛坑在这题了,TAT.... 今天把代码改了下,过掉了,TAT 很明显 ...

  7. 高精度乘法-17南宁区域赛F -The Chosen One

    题目大意:给你一个n,然后从1~n隔一个选一个,挑出一个集合然后从集合中继续隔一个挑一个,直到只有一个数,问最后一个数是多少?2<=n<=1050 例如n=5,先选出2,4最后选择4.n= ...

  8. UVALive - 7740 Coding Contest 2016 青岛区域赛 (费用流)

    题意:每个点i有\(s_i\)个人和\(b_i\)份食物,每个人都要找到一份食物.现在有M条有向边,从点i到点j,容量为c,第一次走过不要紧,从第二次开始就要承担\(p(0<p<1)\)的 ...

  9. 17 南宁区域赛 F - The Chosen One 【规律】

    题目链接 https://nanti.jisuanke.com/t/19972 题意 给出一个n 然后将 n 个数 标号为 1 -> n 按顺序排列 每次抽掉 奇数位的数 然后求最后剩下那个数字 ...

随机推荐

  1. Django Rest framework基础使用之Request/Response

    1.Request restframework提供了一个Request对象(rest_framework.request.Request) Request对象继承了Django默认的HttpReque ...

  2. CodeForces - 1051D-简单DP

    这个题叫问给一个2*N的方块,你可以在每一个上填任意黑或者白两种,假设颜色相同的并且有公共边的就被认为是一块,问组成K块有多少种方案. 这题开始感觉无从下手,像组合数学又不像的,其实这个题的关键在于, ...

  3. jQuery中.html(“xxx”)和.append("xxx")有什么区别

    append是追加,html是完全替换比如<p id="1"><p>123</p></p>$("#1").htm ...

  4. AVAudioSesion和AVAudioPlayer的基本使用

    iOS基础篇-AVPLayer和AVAudioSession 2018.02.27 16:17 字数 215 阅读 1516评论 0喜欢 4 作用 AVPLayer:可以用来播放在线及本地音视频 AV ...

  5. HTML 5 Web 音频

    HTML 5 音频http://www.w3school.com.cn/html5/html_5_audio.asp 在 Web 上播放音频http://www.w3school.com.cn/med ...

  6. 三、taro路由及设计稿及尺寸单位

    一.路由配置 路由配置跟小程序一样,在入口文件的 config 配置中指定好 pages 通过taro API 跳转,详见导航 // 跳转到目的页面,打开新页面 Taro.navigateTo({ u ...

  7. react 路由4 学习

    表单控件 受控表单组件 非受控的表单组件 demo:收集表单提交的数据 路由(V4) 特点:一切皆是组件 官网:https://reacttraining.com/react-router/ npm ...

  8. 虚拟机安装CentOS7之后没有ip的问题

    CentOS 7 默认是不启动网卡的(ONBOOT=no),主要是修改一下网上配置,然后重起便可,看这篇博客操作: https://blog.csdn.net/dancheren/article/de ...

  9. 剑指offer(14)

    题目: 操作给定的二叉树,将其变换为源二叉树的镜像. 思路: 这里有个细节,我们发现,6节点的子节点在操作之后并没有发生变化,所以等会我们在交换的时候,交换的不是节点的数值,而是整个节点. 另外我们进 ...

  10. Android常用的技术框架与博客社区

    技术框架 图片加载 Glide Fresco Volley Picasso Universal Image Loader 网络请求 okhttp retrofit Volley android-asy ...