两两内积为0(牛客多校第七场)-- CDMA
题意:
构造一个n*n的矩阵,元素只能是-1或1,任意两行内积为0(两两相乘加起来和为0)。
思路;

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>//sprintf islower isupper
#include <cstdlib>//malloc exit strcat itoa system("cls")
#include <iostream>//pair
#include <fstream>
#include <bitset>
//#include <map>
//#include<unordered_map>
#include <vector>
#include <stack>
#include <set>
#include <string.h>//strstr substr
#include <string>
#include <time.h>//srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9;
#include <cmath>
#include <deque>
#include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less
#include <vector>//emplace_back
//#include <math.h>
//#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor
#include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare)
using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation
#define fo(a,b,c) for(register int a=b;a<=c;++a)
#define fr(a,b,c) for(register int a=b;a>=c;--a)
#define mem(a,b) memset(a,b,sizeof(a))
#define pr printf
#define sc scanf
#define ls rt<<1
#define rs rt<<1|1
void swapp(int &a,int &b);
double fabss(double a);
int maxx(int a,int b);
int minn(int a,int b);
int Del_bit_1(int n);
int lowbit(int n);
int abss(int a);
//const long long INF=(1LL<<60);
const double E=2.718281828;
const double PI=acos(-1.0);
const int inf=(<<);
const double ESP=1e-;
const int mod=(int)1e9+;
const int N=(int)1e6+; int mp[][]; void same(int cnt)
{
fo(i,,cnt)
{
fo(j,,cnt)
{
mp[i][j+cnt]=mp[i][j];
}
}
} void _(int cnt)
{
fo(i,cnt+,cnt*-)
{
fo(j,,cnt)
mp[i][j]=mp[i-cnt+][j];
fo(j,cnt+,cnt*)
mp[i][j]=-mp[i-cnt+][j];
}
fo(i,,cnt)
mp[cnt*][i]=;
fo(i,cnt+,cnt*)
mp[cnt*][i]=;
} int main()
{
mp[][]=mp[][]=mp[][]=;
int cnt=;
fo(i,,)
{
same(cnt);
_(cnt);
cnt*=;
}
int n;
sc("%d",&n);
fo(i,,n)
fo(j,,n)
pr("%d%c",mp[i][j]==?mp[i][j]:-,j==n?'\n':' ');
return ;
} /**************************************************************************************/ int maxx(int a,int b)
{
return a>b?a:b;
} void swapp(int &a,int &b)
{
a^=b^=a^=b;
} int lowbit(int n)
{
return n&(-n);
} int Del_bit_1(int n)
{
return n&(n-);
} int abss(int a)
{
return a>?a:-a;
} double fabss(double a)
{
return a>?a:-a;
} int minn(int a,int b)
{
return a<b?a:b;
}
两两内积为0(牛客多校第七场)-- CDMA的更多相关文章
- 牛客多校第七场 C Bit Compression 思维
链接:https://www.nowcoder.com/acm/contest/145/C来源:牛客网 A binary string s of length N = 2n is given. You ...
- 2019牛客多校第七场E Find the median 离散化+线段树维护区间段
Find the median 题意 刚开始集合为空,有n次操作,每次操作往集合里面插入[L[i],R[i]]的值,问每次操作后中位数是多少 分析 由于n比较大,并且数可以达到1e9,我们无法通过权值 ...
- 牛客多校第七场H Pair 数位dp理解
Pair 题意 给出A B C,问x取值[1,A]和y取值[1,B]存在多少组pair<x,y>满足以下最小一种条件,\(x \& y >c\),\(x\) xor \(y& ...
- 2019牛客多校第七场 F Energy stones 树状数组+算贡献转化模拟
Energy stones 题意 有n块石头,每块有初始能量E[i],每秒石头会增长能量L[i],石头的能量上限是C[i],现有m次时刻,每次会把[s[i],t[i]]的石头的能量吸干,问最后得到了多 ...
- Find the median(2019年牛客多校第七场E题+左闭右开线段树)
题目链接 传送门 题意 每次往集合里面添加一段连续区间的数,然后询问当前集合内的中位数. 思路 思路很好想,但是卡内存. 当时写的动态开点线段树没卡过去,赛后机房大佬用动态开点过了,\(tql\). ...
- 2019牛客多校第七场E Find the median 权值线段树+离散化
Find the median 题目链接: https://ac.nowcoder.com/acm/contest/887/E 题目描述 Let median of some array be the ...
- 2019牛客多校第七场H Pair 数位DP
题意:给你一个3个数A, B, C问有多少对pair(i, j),1 <= i <= A, 1 <= j <= B, i AND j > C或 i XOR j < ...
- 2019牛客多校第七场C-Governing sand(线段树+枚举)
Governing sand 题目传送门 解题思路 枚举每一种高度作为最大高度,则需要的最小花费的钱是:砍掉所有比这个高度高的树的所有花费+砍掉比这个高度低的树里最便宜的m棵树的花费,m为高度低的里面 ...
- 牛客多校第七场 C Governing sand 线段树
题意: 有一个树林,树林中不同种类的树有不同的数量,高度,砍伐它们的价格.现在要求砍掉一些树,使得高度最高的树占剩下的树的总数的一半以上,求最小花费. 题解: 用线段树维护不同种类树的信息,叶子节点从 ...
随机推荐
- Python中很少见的用法
print(*range(10)) # 自动解开可迭代的对象
- js获取当前页面url信息
<html> <head> <meta charset="utf-8" /> <title></title> <s ...
- oracle报错:The Network Adapter could not establish the connection的解决
进入oracle安装目录\product\11.2.0\dbhome_1\NETWORK\ADMIN,修改listener.ora和tnsnames.ora,修改host 我的网络IP为192.168 ...
- oracle 中怎样实现分页和去处重复
oracle 中用关键字 rownum 来进行分页 rownum 不能使用大于号,只能是使用小于号,可以使用子查询和rownum一起使用来创建分页 SELECT * FROM ( SELECT e. ...
- Leetcode题目20.有效的括号(简单)
题目描述: 给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效. 有效字符串需满足: 左括号必须用相同类型的右括号闭合.左括号必须以正确的顺序闭合.注意空字符 ...
- 石川es6课程---6、解构赋值
石川es6课程---6.解构赋值 一.总结 一句话总结: 结构相同一一对应的方式赋值:let [json, arr, num, str] = [{ a: 1, b: 2 }, [1, 2, 3], 8 ...
- oc 计算 带括号 式子
下面代码实现可以计算 类似以下的字符窜. @"(1+2*(3+4)+3)/2" 自写一个简单 stack .不知道 OC为什么不提供Stack类. #import <Foun ...
- ftp配置文件详解
### 主配置文件(/etc/vsftpd/vsftpd.conf) 严格来说,整个 vsftpd 的配置文件就只有这个档案!这个档案的设定是以 bash的变量设定相同的方式来处理的, 也就是`参数= ...
- intellij系列编辑器个性化注释说明(定义个人风格的todo)
有时候我们需要用于自己个性化的注释,不为装逼,只为能够快速找到自己的注释,自己的代码,不迷路... 废话少说,孩儿们看过来: 1.打开你的编辑器,打开setting,搜索TODO: 设置完点击保存去试 ...
- 2018年第一记:EDM策略分享-EDM营销的策略分析
很久没有上博客园来更新下文章了,一则因为工作繁忙,二则对技术方面的研究时间花的少了,目前主要侧重于EDM营销方面的策略制定.很多人跟我说,做EDM营销都茫然无头绪,那么做EDM到底有什么策略呢?下面博 ...