日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CDMA(牛客第八场构造题)

發布時間:2023/12/15 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CDMA(牛客第八场构造题) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

鏈接:https://ac.nowcoder.com/acm/contest/888/C
來源:牛客網

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矩陣使得每一行對應位置的數乘積加起來都為零。
典型的構造題,不禁想起來課本上的循環賽程表,根據小的去構造大的,通過給出的m=2的去構造m=4的,然后找出規律后構造出m=8的發現也對,就寫了。代碼中解釋
代碼如下:

#include<bits/stdc++.h> #define ll long long using namespace std;int a[1030][1030]; int n;int main() {while(scanf("%d",&n)!=EOF){a[1][1]=1;a[1][2]=1;a[2][1]=-1;a[2][2]=1;if(n==2){for(int i=1;i<=2;i++){for(int j=1;j<=2;j++)printf("%d ",a[i][j]);printf("\n");}}else{int y=4;while(y<=n){for(int i=y/2+1;i<=y;i++)//左下方的矩陣就等于左上方的矩陣的相反數{for(int j=1;j<=y/2;j++)a[i][j]=-a[i-y/2][j];}for(int i=1;i<=y/4;i++)//右上方的矩陣前兩行左下方的矩陣前兩行{for(int j=y/2+1;j<=y;j++){a[i][j]=a[y/2+i-1][j-y/2];}}for(int i=y/4+1;i<=y/2;i++)//右上方的矩陣后兩行等于左下方的矩陣后兩行的相反數{for(int j=y/2+1;j<=y;j++){a[i][j]=-a[y/2+i-1][j-y/2];}}for(int i=y/2+1;i<=y;i++)//右下方的矩陣就等于右上方的矩陣{for(int j=y/2+1;j<=y;j++)a[i][j]=a[i-y/2][j];}y*=2;}for(int i=1;i<=n;i++){for(int j=1;j<=n;j++){printf("%d ",a[i][j]);}printf("\n");}}} }

努力加油a啊,(o)/~

總結

以上是生活随笔為你收集整理的CDMA(牛客第八场构造题)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。