当前位置:网站首页>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;
}
边栏推荐
- PHP Joseph Ring problem
- Game 280 of leetcode week
- Main window in QT application
- Wechat applet: independent background with distribution function, Yuelao office blind box for making friends
- Kibana installation and configuration
- Include rake tasks in Gems - including rake tasks in gems
- PHP Basics - detailed explanation of DES encryption and decryption in PHP
- R language uses logistic regression and afrima, ARIMA time series models to predict world population
- Win: use PowerShell to check the strength of wireless signal
- R语言用logistic逻辑回归和AFRIMA、ARIMA时间序列模型预测世界人口
猜你喜欢
MATLB | multi micro grid and distributed energy trading
Lsblk command - check the disk of the system. I don't often use this command, but it's still very easy to use. Onion duck, like, collect, pay attention, wait for your arrival!
微信小程序:星宿UI V1.5 wordpress系统资讯资源博客下载小程序微信QQ双端源码支持wordpress二级分类 加载动画优化
Yyds dry goods inventory kubernetes management business configuration methods? (08)
Exploration and practice of integration of streaming and wholesale in jd.com
Interesting practice of robot programming 16 synchronous positioning and map building (SLAM)
增量备份 ?db full
[CTF] AWDP summary (WEB)
【LeetCode】88. Merge two ordered arrays
After reading the average code written by Microsoft God, I realized that I was still too young
随机推荐
MATLB | multi micro grid and distributed energy trading
线上故障突突突?如何紧急诊断、排查与恢复
phpstrom设置函数注释说明
Using openpyxl module to write the binary list into excel file
[swagger]-swagger learning
Pytorch fine tuning (Fortune): hollowed out design or cheating
流批一體在京東的探索與實踐
Heartless sword English translation of Xi Murong's youth without complaint
JS implementation determines whether the point is within the polygon range
Do you know the eight signs of a team becoming agile?
Interesting practice of robot programming 16 synchronous positioning and map building (SLAM)
If the consumer Internet is compared to a "Lake", the industrial Internet is a vast "ocean"
Pytorch common code snippet collection
Huawei machine test question: longest continuous subsequence
Armv8-a programming guide MMU (3)
Valentine's Day flirting with girls to force a small way, one can learn
当产业互联网时代真正发展完善之后,将会在每一个场景见证巨头的诞生
Redis' hyperloglog as a powerful tool for active user statistics
A simple SSO unified login design
Express routing, express middleware, using express write interface