当前位置:网站首页>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;
}
边栏推荐
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- Pickle and savez_ Compressed compressed volume comparison
- Hometown 20 years later (primary school exercises)
- 2021robocom robot developer competition (Preliminary)
- [mathematical modeling] differential equation -- sustainable development of fishing industry
- 關於Unity Inspector上的一些常用技巧,一般用於編輯器擴展或者其他
- Three. JS learning - light and shadow (understanding)
- Sliding window problem review
- Rce code and Command Execution Vulnerability
- Modbus protocol communication exception
猜你喜欢

Microblogging hot search stock selection strategy

图论的扩展

RT thread analysis log system RT_ Kprintf analysis

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

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

TCP three handshakes you need to know

Postman关联

麥斯克電子IPO被終止:曾擬募資8億 河南資產是股東

Pagoda configuration mongodb
![[leetcode16] the sum of the nearest three numbers (double pointer)](/img/99/a167b0fe2962dd0b5fccd2d9280052.jpg)
[leetcode16] the sum of the nearest three numbers (double pointer)
随机推荐
Postman manage test cases
Pix2pix: image to image conversion using conditional countermeasure networks
The IPO of mesk Electronics was terminated: Henan assets, which was once intended to raise 800 million yuan, was a shareholder
[leetcode daily question] number of enclaves
ISP learning (2)
Can the feelings of Xi'an version of "Coca Cola" and Bingfeng beverage rush for IPO continue?
Pickle and savez_ Compressed compressed volume comparison
What are the advantages of the industry private network over the public network? What specific requirements can be met?
The underlying structure of five data types in redis
Drive development - the first helloddk
趋势前沿 | 达摩院语音 AI 最新技术大全
acwing周赛58
關於Unity Inspector上的一些常用技巧,一般用於編輯器擴展或者其他
Compilation et connexion de shader dans games202 - webgl (comprendre la direction)
Postman关联
yolov5 tensorrt加速
idea一键导包
Simple understanding of interpreters and compilers
Postman Association
Codeforces Round #804 (Div. 2) Editorial(A-B)