当前位置:网站首页>Codeforces Round #804 (Div. 2) Editorial(A-B)
Codeforces Round #804 (Div. 2) Editorial(A-B)
2022-07-06 05:14:00 【. Ashy.】
List of articles
C I really don't understand the solution of the question , Write first A,B
A — The Third Three Number Problem
The question
Give a number n , Find any three numbers a b c Satisfy
( a ⊕ b ) + ( b ⊕ c ) + ( a ⊕ c ) = n (a⊕b)+(b⊕c)+(a⊕c)=n (a⊕b)+(b⊕c)+(a⊕c)=n
Ideas
First of all, according to the
a + b = a ⊕ b + 2 ∗ ( a & b ) a+b=a⊕b+2*(a\&b) a+b=a⊕b+2∗(a&b)
This formula shows that
a ⊕ b a⊕b a⊕b The parity of is with a + b a+b a+b same
so ( a ⊕ b ) + ( b ⊕ c ) + ( a ⊕ c ) (a⊕b)+(b⊕c)+(a⊕c) (a⊕b)+(b⊕c)+(a⊕c) The parity of is with ( a + b ) + ( b + c ) + ( a + c ) (a+b)+(b+c)+(a+c) (a+b)+(b+c)+(a+c) same , Is with the 2 ∗ ( a + b + c ) 2*(a+b+c) 2∗(a+b+c) The parity of is the same , so It can be proved that n It must be an even number , Therefore, there is no solution in the case of odd numbers ;
And then the structure , According to the nature a ⊕ 0 = a a⊕0=a a⊕0=a We Can construct 0 0 n 2 n\over2 2n Three numbers
#include<bits/stdc++.h>
using namespace std;
int n,t;
int main()
{
cin>>t;
while(t--)
{
cin>>n;
if(n%2!=0) puts("-1");
else cout<<"0 0 "<<n/2<<endl;
}
}
B — Almost Ternary Matrix
The question
Matrix construction , There are exactly two different blocks that make each block connected
Ideas :

hold n And m Get a little bigger and draw a picture to see the law
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a,b;
int t;
int s[51][51];
int main()
{
cin>>t;
while(t--)
{
cin>>a>>b;
s[1][1]=1;
s[1][2]=0;
s[2][1]=0;
s[2][2]=1;// First construct 2*2 The smallest unit block of
for(int i=3;i<=b;i++)
if(i%2==0) s[1][i]=s[1][i-3];
else s[1][i]=s[1][i-1];
for(int i=3;i<=b;i++)
if(i%2==0) s[2][i]=s[2][i-3];
else s[2][i]=s[2][i-1];// Construct the first two lines
for(int i=3;i<=a;i++)
{
if(i%2==0)
{
for(int j=1;j<=b;j++)
{
s[i][j]=s[i-3][j];
}
}
else
{
for(int j=1;j<=b;j++)
{
s[i][j]=s[i-1][j];
}
}
}// Construct the following line
for(int i=1;i<=a;i++)
{
for(int j=1;j<=b;j++)
{
cout<<s[i][j]<<" ";
}
puts("");
}
}// Output
return 0;
}
边栏推荐
- Can the feelings of Xi'an version of "Coca Cola" and Bingfeng beverage rush for IPO continue?
- 2021robocom robot developer competition (Preliminary)
- Flody的应用
- Postman pre script - global variables and environment variables
- The IPO of mesk Electronics was terminated: Henan assets, which was once intended to raise 800 million yuan, was a shareholder
- Upload nestjs configuration files, configure the use of middleware and pipelines
- 从0到1建设智能灰度数据体系:以vivo游戏中心为例
- idea一键导包
- 组播和广播的知识点梳理
- Postman manage test cases
猜你喜欢

Postman pre script - global variables and environment variables

February 12 relativelayout

MPLS experiment

行业专网对比公网,优势在哪儿?能满足什么特定要求?

The underlying structure of five data types in redis

Why does MySQL need two-phase commit

pix2pix:使用条件对抗网络的图像到图像转换

浅谈镜头滤镜的类型及作用

nacos-高可用seata之TC搭建(02)

GAMES202-WebGL中shader的编译和连接(了解向)
随机推荐
集合详解之 Map + 面试题
RT thread analysis - object container implementation and function
Why does MySQL need two-phase commit
Using stopwatch to count code time
A little knowledge of CPU, disk and memory
February 12 relativelayout
你需要知道的 TCP 三次握手
Oracle query table index, unique constraint, field
[NOIP2009 普及组] 分数线划定
用StopWatch 统计代码耗时
Knowledge points of circular structure
Three. JS learning - light and shadow (understanding)
Leetcode 186 Flip the word II in the string (2022.07.05)
Chip debugging of es8316 of imx8mp
Quelques conseils communs sur l'inspecteur de l'unit é, généralement pour les extensions d'éditeur ou d'autres
Fuzzy -- basic application method of AFL
Golang -- TCP implements concurrency (server and client)
Force buckle 1189 Maximum number of "balloons"
Leetcode dynamic planning day 16
flutter 实现一个有加载动画的按钮(loadingButton)