题意:

构造一个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的更多相关文章

  1. 牛客多校第七场 C Bit Compression 思维

    链接:https://www.nowcoder.com/acm/contest/145/C来源:牛客网 A binary string s of length N = 2n is given. You ...

  2. 2019牛客多校第七场E Find the median 离散化+线段树维护区间段

    Find the median 题意 刚开始集合为空,有n次操作,每次操作往集合里面插入[L[i],R[i]]的值,问每次操作后中位数是多少 分析 由于n比较大,并且数可以达到1e9,我们无法通过权值 ...

  3. 牛客多校第七场H Pair 数位dp理解

    Pair 题意 给出A B C,问x取值[1,A]和y取值[1,B]存在多少组pair<x,y>满足以下最小一种条件,\(x \& y >c\),\(x\) xor \(y& ...

  4. 2019牛客多校第七场 F Energy stones 树状数组+算贡献转化模拟

    Energy stones 题意 有n块石头,每块有初始能量E[i],每秒石头会增长能量L[i],石头的能量上限是C[i],现有m次时刻,每次会把[s[i],t[i]]的石头的能量吸干,问最后得到了多 ...

  5. Find the median(2019年牛客多校第七场E题+左闭右开线段树)

    题目链接 传送门 题意 每次往集合里面添加一段连续区间的数,然后询问当前集合内的中位数. 思路 思路很好想,但是卡内存. 当时写的动态开点线段树没卡过去,赛后机房大佬用动态开点过了,\(tql\). ...

  6. 2019牛客多校第七场E Find the median 权值线段树+离散化

    Find the median 题目链接: https://ac.nowcoder.com/acm/contest/887/E 题目描述 Let median of some array be the ...

  7. 2019牛客多校第七场H Pair 数位DP

    题意:给你一个3个数A, B, C问有多少对pair(i, j),1 <= i <= A, 1 <= j <= B, i AND j > C或 i XOR j < ...

  8. 2019牛客多校第七场C-Governing sand(线段树+枚举)

    Governing sand 题目传送门 解题思路 枚举每一种高度作为最大高度,则需要的最小花费的钱是:砍掉所有比这个高度高的树的所有花费+砍掉比这个高度低的树里最便宜的m棵树的花费,m为高度低的里面 ...

  9. 牛客多校第七场 C Governing sand 线段树

    题意: 有一个树林,树林中不同种类的树有不同的数量,高度,砍伐它们的价格.现在要求砍掉一些树,使得高度最高的树占剩下的树的总数的一半以上,求最小花费. 题解: 用线段树维护不同种类树的信息,叶子节点从 ...

随机推荐

  1. Python3:Collatz 序列(考拉咨猜想)

    编写一个名为collatz()的函数,它有一个名为number的参数: 如果参数是偶数,那么collatz()就打印出number//2,并返回该值: 如果number是奇数,那么collatz()就 ...

  2. axios 的坑

    必须安装axios 和qs 1.main.js中的配置 import axios from 'axios' import qs from 'qs'; axios.defaults.headers.po ...

  3. Bzoj3073Journeys

    这不裸的dij吗?来,弄他. 打完以后发现不妙,这数据范围略神奇……算一算,考一场都可能跑不出来.map去重边(成功额外引入log)不怕,交.TLE,54. 这不玩呢吗,把map去了,交.MLE,71 ...

  4. [心得]暑假DAY 5

    好久没更新博客了 最近事情太多太多 tarjan进阶,点双边双 T2压力 最大坑点:点双缩点 它不是直接把割点连成树(割点会有环) 而是用割点作”中介“,联接点双构成一颗树(所谓圆方树) 接着在上面进 ...

  5. C++之多继承与虚继承

    1. 多继承 1.1 多继承概念 一个类有多个直接基类的继承关系称为多继承 多继承声明语法 class 派生类名 : 访问控制 基类名1, 访问控制 基类名2, ... { 数据成员和成员函数声明 } ...

  6. 用python绘制趋势图

    import matplotlib.pyplot as plt #plt用于显示图片 import matplotlib.image as mping #mping用于读取图片 import date ...

  7. AsyncTaskMethodBuilder

    AsyncTaskMethodBuilder Represents a builder for asynchronous methods that return a task. public stru ...

  8. ul 加 li 实现 select 下拉选功能

    由于 select 没有选中事件(onchange 事件在内容改变时才会触发,选择同一个条目不会触发),只好用其他控件来实现. <!doctype html> <html lang= ...

  9. 前端性能之Chrome的Waterfall

    浏览器根据HTML中外连资源出现的顺序,依次放入队列(队列),然后根据优先级确定向服务器获取资源的顺序.同优先级的资源根据HTML中出现的先后顺序来向服务器获取资源. 瀑布中各项内容的含义: 排队: ...

  10. 自定义组合控件SettingItemView的简单实现

    package com.loaderman.settingitemviewdemo; import android.os.Bundle; import android.support.v7.app.A ...