当前位置:网站首页>Codeforces Round #804 (Div. 2) Editorial(A-B)
Codeforces Round #804 (Div. 2) Editorial(A-B)
2022-07-06 05:11:00 【.Ashy.】
C的题解着实看不懂,先写写 A,B
A — The Third Three Number Problem
题意
给出一个数 n ,找出任意三个数 a b c 满足
( a ⊕ b ) + ( b ⊕ c ) + ( a ⊕ c ) = n (a⊕b)+(b⊕c)+(a⊕c)=n (a⊕b)+(b⊕c)+(a⊕c)=n
思路
首先根据
a + b = a ⊕ b + 2 ∗ ( a & b ) a+b=a⊕b+2*(a\&b) a+b=a⊕b+2∗(a&b)
这个式子可知
a ⊕ b a⊕b a⊕b 的奇偶性是与 a + b a+b a+b 相同的
故 ( a ⊕ b ) + ( b ⊕ c ) + ( a ⊕ c ) (a⊕b)+(b⊕c)+(a⊕c) (a⊕b)+(b⊕c)+(a⊕c)的奇偶性是与 ( a + b ) + ( b + c ) + ( a + c ) (a+b)+(b+c)+(a+c) (a+b)+(b+c)+(a+c) 相同的,是与 2 ∗ ( a + b + c ) 2*(a+b+c) 2∗(a+b+c) 的奇偶性相同 ,故 可证得 n 一定是个偶数 , 故在奇数情况下无解;
然后是构造,根据性质 a ⊕ 0 = a a⊕0=a a⊕0=a 我们 可以构造 0 0 n 2 n\over2 2n 三个数
#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
题意
矩阵构造,使得每个块相连的块与其不同的恰好只有两个
思路:
把 n 与 m 取得稍大一点画出图既能看出规律
#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;//先构造 2*2 的最小单位块
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];//构造前两行
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];
}
}
}//构造后面行
for(int i=1;i<=a;i++)
{
for(int j=1;j<=b;j++)
{
cout<<s[i][j]<<" ";
}
puts("");
}
}//输出
return 0;
}
边栏推荐
- Introduction of several RS485 isolated communication schemes
- [数学建模] 微分方程--捕鱼业的持续发展
- Postman断言
- [noip2008 improvement group] stupid monkey
- Mysql高级篇学习总结9:创建索引、删除索引、降序索引、隐藏索引
- Ad20 is set with through-hole direct connection copper sheet, and the bonding pad is cross connected
- 行业专网对比公网,优势在哪儿?能满足什么特定要求?
- idea一键导包
- Pagoda configuration mongodb
- 2021robocom robot developer competition (Preliminary)
猜你喜欢
February 12 relativelayout
Flody的应用
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
Cve-2019-11043 (PHP Remote Code Execution Vulnerability)
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
Postman pre script - global variables and environment variables
Simple understanding of interpreters and compilers
acwing周赛58
What are the advantages of the industry private network over the public network? What specific requirements can be met?
随机推荐
Vite configures the development environment and production environment
flutter 实现一个有加载动画的按钮(loadingButton)
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
Summary of three log knowledge points of MySQL
关于es8316的音频爆破音的解决
Realize a binary read-write address book
F12 solve the problem that web pages cannot be copied
Review of double pointer problems
Implementing fuzzy query with dataframe
Raspberry pie 3.5-inch white screen display connection
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
[classic example] binary tree recursive structure classic topic collection @ binary tree
Yyds dry inventory SSH Remote Connection introduction
Drive development - the first helloddk
[effective Objective-C] - memory management
What are the advantages of the industry private network over the public network? What specific requirements can be met?
Simple understanding of interpreters and compilers
麥斯克電子IPO被終止:曾擬募資8億 河南資產是股東
Basic knowledge and examples of binary tree
pix2pix:使用条件对抗网络的图像到图像转换