CDMA(牛客第八场构造题)
鏈接:https://ac.nowcoder.com/acm/contest/888/C
來源:牛客網(wǎng)
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∑
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∈{2
k
∣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.
構造1,-1矩陣使得每一行對應位置的數(shù)乘積加起來都為零。
典型的構造題,不禁想起來課本上的循環(huán)賽程表,根據(jù)小的去構造大的,通過給出的m=2的去構造m=4的,然后找出規(guī)律后構造出m=8的發(fā)現(xiàn)也對,就寫了。代碼中解釋
代碼如下:
努力加油a啊,(o)/~
總結
以上是生活随笔為你收集整理的CDMA(牛客第八场构造题)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Gemstones(牛客第八场多校)
- 下一篇: Quadratic equation(二