当前位置:网站首页>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;
}
边栏推荐
- IPv6 comprehensive experiment
- ISP learning (2)
- Force buckle 1189 Maximum number of "balloons"
- Ad20 is set with through-hole direct connection copper sheet, and the bonding pad is cross connected
- Raspberry pie 3.5-inch white screen display connection
- 2022半年总结
- 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
- nacos-高可用seata之TC搭建(02)
- What are the advantages of the industry private network over the public network? What specific requirements can be met?
- L'introduction en bourse de MSK Electronics a pris fin: 800 millions de RMB d'actifs de Henan étaient des actionnaires
猜你喜欢

Ad20 is set with through-hole direct connection copper sheet, and the bonding pad is cross connected

Flody的应用

Compilation and connection of shader in games202 webgl (learn from)

Vite configures the development environment and production environment

Three methods of Oracle two table Association update

In 2022, we must enter the big factory as soon as possible

Nacos TC setup of highly available Seata (02)

Nacos - TC Construction of High available seata (02)

Principle and performance analysis of lepton lossless compression

ISP learning (2)
随机推荐
Acwing week 58
Summary of redis basic knowledge points
[noip2008 improvement group] stupid monkey
CUDA11.1在线安装
Steady, 35K, byte business data analysis post
Class inheritance in yyds dry inventory C
[lgr-109] Luogu may race II & windy round 6
yolov5 tensorrt加速
IPv6 comprehensive experiment
图数据库ONgDB Release v-1.0.3
C AES encrypts strings
Golang -- TCP implements concurrency (server and client)
JS quick start (II)
Rce code and Command Execution Vulnerability
Codeforces Round #804 (Div. 2) Editorial(A-B)
Review of double pointer problems
驱动开发——HelloWDM驱动
Summary of redis AOF and RDB knowledge points
Driver development - hellowdm driver
Hyperledger Fabric2. Some basic concepts of X (1)