观察前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. computed配合watch监听对象数据

  2. python 查询文件修改python lib 库文件

    运行code import os, time import sys import re def search(path, name): for root, dirs, files in os.walk ...

  3. 《OKR工作法》–让所有人承担自己的职责

    <OKR工作法>中提到了一个创业故事,TeaBee,创业的目标是让喜欢喝茶的人喝到好茶. 创业初期作为首席执行官的汉娜和作为总裁的杰克就在将茶叶提供给餐厅还是餐厅供应商上产生了分歧,随后他 ...

  4. 2019.11.30 Mysql查询知识

    不等于:<> 判断为空的条件:null和空格(空字符串) 判断是否为null:xxxx  is  not  null    /    xxxx   is   null 判断null: SE ...

  5. 特征缩放(Feature Scaling)

    特征缩放的几种方法: (1)最大最小值归一化(min-max normalization):将数值范围缩放到 [0, 1] 区间里 (2)均值归一化(mean normalization):将数值范围 ...

  6. mysql left()函数

    mysql> select * from test; +----+------------+-------+-----------+ | id | name | score | subject ...

  7. nacos启动与sql8.0的问题解决方法

    hi all! 半年多没更新,是不是以为我消失了……直接正题~ 在搭建nacos环境的时候,有这样的一项:数据库持久化配置.(官方文档),这个配置可以灵活的帮我们进行配置而不用总是重启服务. 那么问题 ...

  8. 刷题记录:[De1ctf] shell shell shell

    目录 刷题记录:[De1ctf] shell shell shell 一.知识点 1.源码泄露 2.正则表达式不完善导致sql注入 3.soapclient反序列化->ssrf 4.扫描内网 5 ...

  9. 第09组 Alpha冲刺(2/4)

    队名:软工9组 组长博客:https://www.cnblogs.com/cmlei/ 作业博客:http://edu.cnblogs.com/campus/fzu/SoftwareEngineeri ...

  10. PHP系列 | PHP5.6 安装 endroid/qr-code 遇到的问题

    官方库地址:https://packagist.org/packages/endroid/qr-code PHP5.6 的最高版本为:2.5.1 通过composer安装 composer requi ...