观察前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. HBase的二级索引

    使用HBase存储中国好声音数据的案例,业务描述如下: 为了能高效的查询到我们需要的数据,我们在RowKey的设计上下了不少功夫,因为过滤RowKey或者根据RowKey查询数据的效率是最高的,我们的 ...

  2. Windows10安装Redis过程

    下载 Redis下载地址:https://github.com/microsoftarchive/redis/releases 以3.2.100版本为例,下载Redis-x64-3.2.100.zip ...

  3. P2915 [USACO08NOV] Mixed Up Cows

    题目描述 Each of Farmer John's N (4 <= N <= 16) cows has a unique serial number S_i (1 <= S_i & ...

  4. 求x,y中的最大值

    分析: 输入——变量x,y存放输入的两个整数: 输出——变量m存放输入的两个整数的最大值,m为输出: 算法——如果x比y大,x赋给m,否则y赋给m. #include<stdio.h>vo ...

  5. PDB文件会影响性能吗?

    有人问了这样的问题:"我工作的公司正极力反对用生成的调试信息构建发布模式二进制文件,这也是我注册该类的原因之一.他们担心演示会受到影响.我的问题是,在发布模式下生成符号的最佳命令行参数是什么 ...

  6. 有效的minidump(二)

    函数MiniDumpCallback 如果要自定义MINIDUMP类型标志无法访问的MINIDUMP的内容,可以使用MiniDumpCallback函数.这是一个用户定义的回调,当MiniDumpWr ...

  7. 用于未处理异常错误的.NET框架清理工具

    当你启动某些程序时,会收到与此错误类似的未处理异常错误:Unhandled e0434f4dh exception at 7c81eb33h.此问题是由于.NET框架未正确安装或.NET框架系统中的另 ...

  8. PHP全栈学习笔记33

    javascript能做什么? 语句与注解,标识符,字面量,变量命名规范 JavaScript中的数据类型,其它类型如何转为数据型,操作符 字符方法,数组方法,函数与对象,函数表达式,变量作用域,对象 ...

  9. A. Vova and Train ( Codeforces Round #515 (Div. 3) )

    题意:一条 L 长的路,一列车长在这条路的 l 到 r 之间,只有在 v 倍数时有灯,但是在 l 到 r 之间的灯是看不见的,问最大看见的灯的个数? 题解:L / v 表示总共的灯的个数, r / v ...

  10. fluent运行过程中转换边界

    我们以一个简单的VOF算例来说明,算例模型如下: 算例中空气为主相,水为次相.开始时刻,inlet_one设置为速度入口边界,速度为1m/s,且水的体积分数为100%,inlet_two设置为速度入口 ...