时间限制:C/C++ 1秒,其他语言2秒

空间限制:C/C++ 524288K,其他语言1048576K
Special Judge, 64bit IO Format: %lld

题目描述

  Gromah and LZR have entered the third level. There is a blank grid of size m×mm\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​ in the sequence as −1, and regard 1​ as +1​, then these sequences should satisfy that for any two different sequences s,t​, the inner product of s,t,t​ should be exactly 0​.

  The inner product of two sequences s,t​ with the same length n equals to ​.
  So, the key to the next level is to construct a grid of size m×m, whose elements are all −1​ or 1​, and for any two different rows, the inner product of them should be exactly 0​.

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

输入描述:

Only one positive integer m​ in one line.   m∈{2k  ∣  k=1,2,⋯ ,10}

输出描述:

Print m​ lines, each contains a sequence with length m​, whose elements should be all −1 or 1​ satisfying that for any two different rows, the inner product of them equals 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.

输入

2

输出

1 1
1 -1

题意:构造由-1,1组成的m*m矩阵,使得任意两行的对应位置乘积和为0。

题解:

代码:

#include<bits/stdc++.h>
using namespace std;
int ans[1200][1200];
void solve(int x,int y,int n,int w);
int main()
{int i,j,n;scanf("%d",&n);solve(1,1,n,1);for(i=1;i<=n;i++)for(j=1;j<=n;j++) printf("%d%c",ans[i][j],j==n?'\n':' ');system("pause");return 0;
}
void solve(int x,int y,int n,int w)
{if(n==1){ans[x][y]=w;return ;}solve(x,y,n/2,w);solve(x,y+n/2,n/2,w);solve(x+n/2,y,n/2,w);solve(x+n/2,y+n/2,n/2,-1*w);
}

转载于:https://www.cnblogs.com/VividBinGo/p/11332784.html

2019牛客暑期多校训练营(第八场) CDMA相关推荐

  1. 【2019牛客暑期多校训练营(第二场) - H】Second Large Rectangle(单调栈,全1子矩阵变形)

    题干: 链接:https://ac.nowcoder.com/acm/contest/882/H 来源:牛客网 题目描述 Given a N×MN \times MN×M binary matrix. ...

  2. 2019牛客暑期多校训练营(第一场)E-ABBA(dp)

    链接:https://ac.nowcoder.com/acm/contest/881/E 来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 524288K,其他语言1048 ...

  3. 2019牛客暑期多校训练营(第一场)

    传送门 参考资料: [1]:官方题解(提取码:t050 ) [2]:标程(提取码:rvxr ) [3]:牛客题解汇总 A.Equivalent Prefixes(单调栈) •题意 定义两个数组 u,v ...

  4. 2019牛客暑期多校训练营(第一场) A Equivalent Prefixes ( st 表 + 二分+分治)

    链接:https://ac.nowcoder.com/acm/contest/881/A 来源:牛客网 Equivalent Prefixes 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/ ...

  5. 【2019牛客暑期多校训练营(第二场)- E】MAZE(线段树优化dp,dp转矩阵乘法,线段树维护矩阵乘法)

    题干: 链接:https://ac.nowcoder.com/acm/contest/882/E?&headNav=acm 来源:牛客网 Given a maze with N rows an ...

  6. 【2019牛客暑期多校训练营(第二场)- F】Partition problem(dfs,均摊时间优化)

    题干: 链接:https://ac.nowcoder.com/acm/contest/882/F 来源:牛客网 Given 2N people, you need to assign each of ...

  7. 【2019牛客暑期多校训练营(第二场) - D】Kth Minimum Clique(bfs,tricks)

    题干: 链接:https://ac.nowcoder.com/acm/contest/882/D 来源:牛客网 Given a vertex-weighted graph with N vertice ...

  8. 【2019牛客暑期多校训练营(第一场) - A】Equivalent Prefixes(单调栈,tricks)

    题干: 链接:https://ac.nowcoder.com/acm/contest/881/A 来源:牛客网 Two arrays u and v each with m distinct elem ...

  9. 【2019牛客暑期多校训练营(第一场) - H】XOR(线性基,期望的线性性)

    题干: 链接:https://ac.nowcoder.com/acm/contest/881/H 来源:牛客网 Bobo has a set A of n integers a1,a2,-,ana1, ...

最新文章

  1. 对人脑而言,阅读计算机代码和阅读语言有何不同?
  2. Prometheus AlertManager 微信报警配置
  3. linux下的QQ执行玩法:pidgin-lwqq
  4. Use DynamicXElement to create xml
  5. 阿里云服务器如何加强服务器的安全?有哪些安全措施?
  6. OpenCV学习笔记(五十六)——InputArray和OutputArray的那些事core OpenCV学习笔记(五十七)——在同一窗口显示多幅图片 OpenCV学习笔记(五十八)——读《Mast
  7. 关闭Outlook时最小化
  8. OPA 11 - how is check called in my iClickTheCreateButton
  9. linux g++ undefined reference to `dlopen'类问题
  10. 简单调整配置深度Linux-15迅速开始学习工作
  11. JavaScript BOM编程
  12. 如何去掉桌面图标快捷方式的小箭头(小技巧)
  13. cadence如何导入gds_Tanner LEdit系列 | 导入GDSII文件
  14. Costco已来华,会员制电商是否迎来爆发增长期?
  15. 报错:UnicodeDecodeError:: ‘utf-8‘ codec can‘t decode byte 0xc8 in position 0: invalid contin
  16. java线性规划计算最优解算法
  17. dmp标签_[重磅推荐]你必须知道的京准通DMP知识!
  18. 企业如何使用商业智能(BI)进行数据赋能?
  19. 树莓派拍照命令——raspistill
  20. 优信拍集团php面试题_【优信拍PHP高级工程师面试一般都会问什么问题?】-看准网...

热门文章

  1. 答大三犹豫考研的同学兼向大一学生叨叨几句
  2. 时光机之殇---微博告别信
  3. linux防火墙富规则,[Linux]Redhat7防火墙配置汇总
  4. npm ERR! code ELIFECYCLEnpm ERR! errno 1npm ERR! wlwl-dsfvue@1.0.0 dev: `node build/dev-server.js`报错
  5. 如何制作U盘启动盘来安装电脑系统
  6. hbuilderx安装教程_HBuilderX入门教程
  7. windows 任务管理器_如何在Windows 10的任务管理器中查看电源使用情况
  8. SpringBoot 接口数据加解密技巧
  9. 豆瓣爬虫(从剧名获取ID)
  10. java递归处理单位人员组织机构树