观察前3组可以推出递归规律,生成下一个类型时,每行copy自身与自身相反。

题目描述

Gromah and LZR have entered the third level. There is a blank grid of size m\times mm×m, and above the grid is a word "CDMA".
 

In CDMA Technology, a Technology about computer network, every network node should be appointed a unique binary sequence with a fixed and the same length. Moreover, if we regard 0_{}0​ in the sequence as -1_{}−1​, and regard 1_{}1​ as +1_{}+1​, then these sequences should satisfy that for any two different sequences s,t_{}s,t​, the inner product of s,t_{}s,t​ should be exactly 0_{}0​.

 
The inner product of two sequences s,t_{}s,t​ with the same length n_{}n​ equals to \sum_{i=1}^{n} s_it_i∑i=1n​si​ti​.
 
So, the key to the next level is to construct a grid of size m\times mm×m, whose elements are all -1_{}−1​ or 1_{}1​, and for any two different rows, the inner product of them should be exactly 0_{}0​.
 

In this problem, it is guaranteed that m_{}m​ is a positive integer power of 2_{}2​ and there exists some solutions for input m_{}m​. If there are multiple solutions, you may print any of them.

输入描述:

Only one positive integer m_{}m​ in one line.
 
m \in \{2^k \; | \;k = 1, 2, \cdots, 10\}m∈{2k∣k=1,2,⋯,10}

输出描述:

Print m_{}m​ lines, each contains a sequence with length m_{}m​, whose elements should be all -1_{}−1​ or 1_{}1​ satisfying that for any two different rows, the inner product of them equals 0_{}0​.

You may print multiple blank spaces between two numbers or at the end of each line, and you may print any number of blank characters at the end of whole output file.
示例1

输入

复制

2

输出

复制

1 1
1 -1

说明

The inner product of the two rows is 1\times(-1) + 1\times 1 = 01×(−1)+1×1=0.

代码如下
 #include <iostream>
#include <math.h>
using namespace std;
char a[][];
int main(){
int n,m,aa();
a[][]='';
a[][]='';
a[][]='';
a[][]='';
cin>>n;
if(n==){
cout<<"1 1\n";
cout<<"1 -1\n";
return ;
}
m=log2(n)-;
while(m--){
aa=aa*;
for(int k=, t=aa;k<aa;k++,t++){
for(int i=,j=aa;j<*aa;j++,i++){
if(a[k][i]=='') {
a[k][j]='';
a[t][i]='';
a[t][j]='';
}
else {
a[k][j]='';
a[t][i]='';
a[t][j]='';
}
}
}
}
for(int i=;i<n;i++){
for(int j=;j<n;j++){
if(a[i][j]=='') cout<<"1 ";
else cout<<"-1 ";
}
cout<<'\n';
}
}



2019暑假牛客多校训练-第八场-C-CDMA(递归、水题)的更多相关文章

  1. 牛客多校训练第八场C.CDMA(思维+构造)

    题目传送门 题意: 输入整数m( m∈2k ∣ k=1,2,⋯,10),构造一个由1和-1组成的m×m矩阵,要求对于任意两个不同的行的内积为0. 题解: Code: #include<bits/ ...

  2. 牛客多校训练第八场G.Gemstones(栈模拟)

    题目传送门 题意: 输入一段字符串,字符串中连续的三个相同的字符可以消去,消去后剩下的左右两段字符串拼接,求最多可消去次数. 输入:ATCCCTTG   输出:2 ATCCCTTG(消去CCC)——& ...

  3. 2019牛客多校训练第四场K.number(思维)

    题目传送门 题意: 输入一个只包含数字的字符串,求出是300的倍数的子串的个数(不同位置的0.00.000等都算,并考虑前导零的情况). sample input: 600 1230003210132 ...

  4. 2019牛客多校训练第三场H.Magic Line(思维)

    题目传送门 大致题意: 输入测试用例个数T,输入点的个数n(n为偶数),再分别输入n个不同的点的坐标,要求输出四个整数x1,y1,x2,y2,表示有一条经过点(x1,y1),(x2,y2)的直线将该二 ...

  5. 2019牛客多校训练第三场B.Crazy Binary String(思维+前缀和)

    题目传送门 大致题意: 输入整数n(1<=n<=100000),再输入由n个0或1组成的字符串,求该字符串中满足1和0个数相等的最长子串.子序列. sample input: 801001 ...

  6. 2019年牛客多校第一场B题Integration 数学

    2019年牛客多校第一场B题 Integration 题意 给出一个公式,求值 思路 明显的化简公式题,公式是分母连乘形式,这个时候要想到拆分,那如何拆分母呢,自然是裂项,此时有很多项裂项,我们不妨从 ...

  7. Cutting Bamboos(2019年牛客多校第九场H题+二分+主席树)

    题目链接 传送门 题意 有\(n\)棵竹子,然后有\(q\)次操作,每次操作给你\(l,r,x,y\),表示对\([l,r]\)区间的竹子砍\(y\)次,每次砍伐的长度和相等(自己定砍伐的高度\(le ...

  8. Distance(2019年牛客多校第八场D题+CDQ+树状数组)

    题目链接 传送门 思路 这个题在\(BZOJ\)上有个二维平面的版本(\(BZOJ2716\)天使玩偶),不过是权限题因此就不附带链接了,我也只是在算法进阶指南上看到过,那个题的写法是\(CDQ\), ...

  9. 2019年牛客多校第四场 B题xor(线段树+线性基交)

    题目链接 传送门 题意 给你\(n\)个基底,求\([l,r]\)内的每个基底是否都能异或出\(x\). 思路 线性基交板子题,但是一直没看懂咋求,先偷一份咖啡鸡板子写篇博客吧~ 线性基交学习博客:传 ...

随机推荐

  1. node爬虫爬取中文时乱码问题 | nodejs gb2312、GBK中文乱码解决方法

    iconv需要依赖native库,这样一来,在一些不支持native模块安装的虚拟主机和windows平台上,我们还是无法安心处理GBK编码. 老外写了一个通过纯Javascript转换编码的模块 i ...

  2. 前端知识--控制input按钮的可用和不可用

    最近在项目的开发的时候,自己虽然是写后端的,但是,在开发核心的时候,前端的知识自己还是会用到的,多以前端这块自己由于好长时间都没有去看,所以几乎已经忘记的差不多了,现在也只能是想起一点记录一点,以便能 ...

  3. maven 使用dependencyManagement统一管理依赖版本

    今日思语:人生方方长长,努力把她磨成方圆,所以 加油咯~ 使用maven可以很方便的进行项目依赖的管理,即可以管理我们显示引入具体版本的依赖,也可以管理某些第三方引入的一些依赖的版本,从而能更好的实现 ...

  4. C++内存分配/分布——堆栈存储区

    FROM: C++内存分配方式详解——堆.栈.自由存储区.全局/静态存储区和常量存储区 栈,就是那些由编译器在需要的时候分配,在不需要的时候自动清除的变量的存储区.里面的变量通常是局部变量.函数参数等 ...

  5. Jmeter扩展自定义函数

    步骤1.导入lib\ext下ApacheJMeter_core.jar和ApacheJMeter_functions.jar 步骤2.新建function的类的package声明必须已".f ...

  6. SpringCloud过滤filter

    目录 配置文件 application.yml eureka: client: service-url: defaultZone: http://localhost:8001/eureka serve ...

  7. 用OKR提升员工的执行力

    很多管理者在公司管控的过程中常常出现一种乏力的感觉,觉得很多事情推进不下去,结果总是令人不满意.管理者总是会吐槽,“员工执行力差!”而此时大部分管理者会认为公司执行力差是员工能力和态度的问题. 事实上 ...

  8. learning java FileVisitor 遍丽文件及路径

    import java.io.IOException; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttribut ...

  9. Fast + Small Docker Image Builds for Rust Apps

    转自:https://shaneutt.com/blog/rust-fast-small-docker-image-builds/ In this post I’m going to demonstr ...

  10. [RN] React Native 使用 react-navigation 报错 "Unable to resolve module `react-native-gesture-handler`

    在React Native 使用 react-navigation 过程中,报错 "Unable to resolve module `react-native-gesture-handle ...