当前位置:网站首页>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;
}
边栏推荐
- 驱动开发——第一个HelloDDK
- Why does MySQL need two-phase commit
- What are the advantages of the industry private network over the public network? What specific requirements can be met?
- 图论的扩展
- 关于es8316的音频爆破音的解决
- nacos-高可用seata之TC搭建(02)
- Fiddler installed the certificate, or prompted that the certificate is invalid
- Nacos - TC Construction of High available seata (02)
- Codeforces Round #804 (Div. 2)
- Please wait while Jenkins is getting ready to work
猜你喜欢
Vite configures the development environment and production environment
ORM aggregate query and native database operation
Postman断言
GAMES202-WebGL中shader的編譯和連接(了解向)
【OSPF 和 ISIS 在多路访问网络中对掩码的要求】
Introduction of several RS485 isolated communication schemes
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
ISP learning (2)
Leetcode dynamic planning day 16
JS quick start (II)
随机推荐
从0到1建设智能灰度数据体系:以vivo游戏中心为例
Fiddler installed the certificate, or prompted that the certificate is invalid
[buuctf.reverse] 159_[watevrCTF 2019]Watshell
Orm-f & Q object
[classic example] binary tree recursive structure classic topic collection @ binary tree
Zynq learning notes (3) - partial reconfiguration
Postman test report
图数据库ONgDB Release v-1.0.3
Yyds dry inventory SSH Remote Connection introduction
[数学建模] 微分方程--捕鱼业的持续发展
Hyperledger Fabric2. Some basic concepts of X (1)
Easy to understand I2C protocol
你需要知道的 TCP 三次握手
Sliding window problem review
Postman manage test cases
EditorUtility.SetDirty在Untiy中的作用以及应用
ISP学习(2)
Flody的应用
Can the feelings of Xi'an version of "Coca Cola" and Bingfeng beverage rush for IPO continue?
Postman Association