当前位置:网站首页>Luo Gu Pardon prisoners of war
Luo Gu Pardon prisoners of war
2022-07-05 01:42:00 【Stars are not last night 334】
Background
With the help of anti cheating system , Some players who had plagiarized and cheated in the monthly competition were caught !
Title Description
existing 2^n*2^n(n≤10) A cheater stood in a square array and waited kkksc03 Hair fall .kkksc03 Pardon some cheaters . He divided the square matrix into 4 A smaller square matrix , The side length of each smaller matrix is half of the original matrix . All cheaters in the upper left matrix will be pardoned , be left over 3 In a small matrix , Each matrix continues to be divided into 4 A smaller matrix , Then pardon the cheater in the same way …… Until the matrix can no longer be divided . All cheaters who are not pardoned will be punished by Brown name .
give n, Please output the fate of each cheater , among 0 The representative was pardoned ,1 Means not to be pardoned .
Input format
An integer nn.
Output format
2^n*2^n Of 01 matrix , Represents whether everyone is pardoned . There is a space between the numbers .
I/o sample
Input #1 Copy
3
Output #1 Copy
0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0 1 0 0 0 0 1 1 1 1 0 0 0 1 0 0 0 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1
#include<bits/stdc++.h>
using namespace std;
const int N=1024+1; //2 The tenth power of is 1024, We are violent from the beginning , So we have to add one .
int n;
int a[N][N]; // Set the size of the matrix .
int main()
{
scanf("%d",&n);
int maxn=1;
for(int i=1;i<=n;i++) // Find the size of the matrix .
maxn*=2;
for(int j=1;j<=maxn;j++) // Set the last column to 1.
a[j][maxn]=1;
/*
Binary addition is like this :
0+0=0 1+0=1 0+1=1 1+1=0
The sum of the two addends equals 1, Then its result is 1, It is 0.
*/
for(int i=2;i<=maxn;i++) // Be careful i from 2 Start , Because the first line except the last one is 1, Everything else is 0
for(int j=1;j<=maxn;j++)
if(a[i-1][j]+a[i-1][j+1]==1) a[i][j]=1; // The result of this value is equal to a[i-1][j]+a[i-1][j+1]
else a[i][j]=0;
for(int i=1;i<=maxn;i++) // Finally, the output matrix .
{
for(int j=1;j<=maxn;j++)
printf("%d ",a[i][j]);
printf("\n");
}
return 0;
}
边栏推荐
- Are you still writing the TS type code
- Behind the cluster listing, to what extent is the Chinese restaurant chain "rolled"?
- 如何搭建一支搞垮公司的技術團隊?
- 85.4% mIOU! NVIDIA: using multi-scale attention for semantic segmentation, the code is open source!
- Introduction to the gtid mode of MySQL master-slave replication
- Global and Chinese market of network connected IC card smart water meters 2022-2028: Research Report on technology, participants, trends, market size and share
- PHP wechat official account development
- MATLB|多微电网及分布式能源交易
- batchnorm.py这个文件单GPU运行报错解决
- The server time zone value ‘� й ��� ʱ 'is unrecognized or representatives more than one time zone【
猜你喜欢
Win:使用 Shadow Mode 查看远程用户的桌面会话
Wechat applet; Gibberish generator
微信小程序:最新wordpress黑金壁纸微信小程序 二开修复版源码下载支持流量主收益
To sort out messy header files, I use include what you use
runc hang 导致 Kubernetes 节点 NotReady
Five ways to query MySQL field comments!
[flutter topic] 64 illustration basic textfield text input box (I) # yyds dry goods inventory #
Wechat applet: independent background with distribution function, Yuelao office blind box for making friends
[development of large e-commerce projects] performance pressure test - Optimization - impact of middleware on performance -40
Nebula importer data import practice
随机推荐
Common bit operation skills of C speech
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
MATLB|多微电网及分布式能源交易
【LeetCode】88. Merge two ordered arrays
Win: enable and disable USB drives using group policy
Win:将一般用户添加到 Local Admins 组中
Wechat applet: the latest WordPress black gold wallpaper wechat applet two open repair version source code download support traffic main revenue
微信小程序:微群人脉微信小程序源码下载全新社群系统优化版支持代理会员系统功能超高收益
node工程中package.json文件作用是什么?里面的^尖括号和~波浪号是什么意思?
Application and Optimization Practice of redis in vivo push platform
JS implementation determines whether the point is within the polygon range
Mysql database | build master-slave instances of mysql-8.0 or above based on docker
220213c language learning diary
Main window in QT application
Database postragesq BSD authentication
Yyds dry goods inventory [Gan Di's one week summary: the most complete and detailed in the whole network]; detailed explanation of MySQL index data structure and index optimization; remember collectio
[development of large e-commerce projects] performance pressure test - Performance Monitoring - heap memory and garbage collection -39
[development of large e-commerce projects] performance pressure test - Optimization - impact of middleware on performance -40
Global and Chinese market of portable CNC cutting machines 2022-2028: Research Report on technology, participants, trends, market size and share
Wechat applet; Gibberish generator