2019暑假牛客多校训练-第八场-C-CDMA(递归、水题)
观察前3组可以推出递归规律,生成下一个类型时,每行copy自身与自身相反。
题目描述
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.
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.
输入描述:
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.
说明
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(递归、水题)的更多相关文章
- 牛客多校训练第八场C.CDMA(思维+构造)
题目传送门 题意: 输入整数m( m∈2k ∣ k=1,2,⋯,10),构造一个由1和-1组成的m×m矩阵,要求对于任意两个不同的行的内积为0. 题解: Code: #include<bits/ ...
- 牛客多校训练第八场G.Gemstones(栈模拟)
题目传送门 题意: 输入一段字符串,字符串中连续的三个相同的字符可以消去,消去后剩下的左右两段字符串拼接,求最多可消去次数. 输入:ATCCCTTG 输出:2 ATCCCTTG(消去CCC)——& ...
- 2019牛客多校训练第四场K.number(思维)
题目传送门 题意: 输入一个只包含数字的字符串,求出是300的倍数的子串的个数(不同位置的0.00.000等都算,并考虑前导零的情况). sample input: 600 1230003210132 ...
- 2019牛客多校训练第三场H.Magic Line(思维)
题目传送门 大致题意: 输入测试用例个数T,输入点的个数n(n为偶数),再分别输入n个不同的点的坐标,要求输出四个整数x1,y1,x2,y2,表示有一条经过点(x1,y1),(x2,y2)的直线将该二 ...
- 2019牛客多校训练第三场B.Crazy Binary String(思维+前缀和)
题目传送门 大致题意: 输入整数n(1<=n<=100000),再输入由n个0或1组成的字符串,求该字符串中满足1和0个数相等的最长子串.子序列. sample input: 801001 ...
- 2019年牛客多校第一场B题Integration 数学
2019年牛客多校第一场B题 Integration 题意 给出一个公式,求值 思路 明显的化简公式题,公式是分母连乘形式,这个时候要想到拆分,那如何拆分母呢,自然是裂项,此时有很多项裂项,我们不妨从 ...
- Cutting Bamboos(2019年牛客多校第九场H题+二分+主席树)
题目链接 传送门 题意 有\(n\)棵竹子,然后有\(q\)次操作,每次操作给你\(l,r,x,y\),表示对\([l,r]\)区间的竹子砍\(y\)次,每次砍伐的长度和相等(自己定砍伐的高度\(le ...
- Distance(2019年牛客多校第八场D题+CDQ+树状数组)
题目链接 传送门 思路 这个题在\(BZOJ\)上有个二维平面的版本(\(BZOJ2716\)天使玩偶),不过是权限题因此就不附带链接了,我也只是在算法进阶指南上看到过,那个题的写法是\(CDQ\), ...
- 2019年牛客多校第四场 B题xor(线段树+线性基交)
题目链接 传送门 题意 给你\(n\)个基底,求\([l,r]\)内的每个基底是否都能异或出\(x\). 思路 线性基交板子题,但是一直没看懂咋求,先偷一份咖啡鸡板子写篇博客吧~ 线性基交学习博客:传 ...
随机推荐
- linux中添加自定义命令
centos下设置alias别名,比较简单,例如: vim /root/.bashrc addalias rm='rm -i' Linux alias设置指令的别名命令详解 功能说明:设置指令的别名. ...
- 怎样把txt文档转换成csv文件?
其实csv就是逗号隔开的一行一行的数据, 如果每行数据中都是用逗号分隔的,直接把文件后缀txt改成csv就行了. 用python搞定: import numpy as np import pandas ...
- fullcalendar + qTip2显示事件详情
fullcalendar 是一个很优秀的日历插件.qTip2 是一个强大的提示工具.在讲下面的功能之前,需要对fullcalendar 和 qTip2 有些了解,可直接点击下面贴出的2个地址: ful ...
- SQL Server 父子迭代查询语句,树状查询
这个也有用: -- Get childs by parent idWITH TreeAS( SELECT Id,ParentId FROM dbo.Node P WHERE P.Id = 21 -- ...
- .net core 根据已有数据库创建实体Model
这三个引用需要与.net core 版本一致,否则后续其他操作时会出错 可以到NuGET包中找到对应的版本然后添加,或者使用一下语句将版本号修改为.net core对应的版本然后执行 Install- ...
- VS2010中使用boost正则表达式库
1.下载boost库.http://www.boost.org/ 我下载的是boost_1_51_0版本.放在D:\opensource\boost_1_51_0. 2.编译boost库. 执 ...
- CF547E Mike and Friends 后缀自动机+线段树合并
裸题,敲完后没调就过了 ~ code: #include <bits/stdc++.h> using namespace std; #define ll long long #define ...
- Tomcat启动服务报错:Unknown version string [4.0]. Default version will be used.
Tomcat.jdk.web.xml 对应关系: 版本对应错误,更换便可.(版本往下兼容) web.xml——version2.2——JDK1.1——Tomcat3.3 web.xml——versio ...
- Xamarin Forms 实现发送通知点击跳转
1. Ensure the you have set LaunchMode.SingleTop on your MainActivity: LaunchMode.SingleTop [Activity ...
- C# await async Task
//原文:https://www.cnblogs.com/yan7/p/8401681.html //原文:https://www.cnblogs.com/s5689412/p/10073507.ht ...