当前位置:网站首页>Codeforces Round #804 (Div. 2)
Codeforces Round #804 (Div. 2)
2022-07-08 01:05:00 【AC automatic mail】
Catalog
A. The Third Three Number Problem
Official explanation
Click the jump : Official explanation
A. The Third Three Number Problem
A. The Third Three Number Problem
Ideas :
First ,⊕( Exclusive or ) Also known as non carry addition , therefore : about (a⊕b)+(b⊕c)+(a⊕c) For the last one of
(a⊕b)+(b⊕c)+(a⊕c) = a + b + b + c + a + c = 2*(a + b + c) Must be an even number
so : When n In an odd number of , unsolvable
When n For even when :
know :a⊕0 = a , therefore , Make a = 0, b = n / 2, c = n / 2;
here :a⊕b = n/2,a⊕c = n/2,b⊕c = 0, The result is n establish
The code is as follows :
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false),cin.tie(0), cout.tie(0)
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 2e5 + 10, mod = 1e9 + 7;
int T;
int lowbit(int x)
{
return x & -x;
}
void solve()
{
int n, c;
scanf("%d", &n);
if(n%2)
{
puts("-1");
return ;
}
printf("%d %d %d\n", 0, n/2, n/2);
//printf("%d\n", res);
}
int main()
{
//fast;
//cin >> T;
scanf("%d", &T);
while(T -- )
solve();
return 0;
}
B. Almost Ternary Matrix
Ideas :
similar :
10011001
01100110
01100110
10011001
Simulate the structure
The code is as follows :
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false),cin.tie(0), cout.tie(0)
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 110, mod = 1e9 + 7;
int T;
int lowbit(int x)
{
return x & -x;
}
void solve()
{
int n, m;
scanf("%d %d", &n, &m);
string r1, r2;
while(true)
{
if(r1.size() < 2 * m) r1 += "1 0 ";
else break;
if(r1.size() < 2 * m) r1 += "0 1 ";
else break;
}
while(true)
{
if(r2.size() < 2 * m) r2 += "0 1 ";
else break;
if(r2.size() < 2 * m) r2 += "1 0 ";
else break;
}
int a[N][N];
for(int i = 1; i <= n; i ++ )
{
if(i % 4 == 1 || i % 4 == 0) cout << r1 << endl;
else cout << r2 << endl;
}
//printf("%d\n", res);
}
int main()
{
//fast;
//cin >> T;
scanf("%d", &T);
while(T -- )
solve();
return 0;
}
This code has a similar effect :
void solve()
{
int n, m;
scanf("%d %d", &n, &m);
for(int i = 1; i <= n; i ++ )
{
for(int j = 1; j <= m; j ++ )
cout << ((i % 4 <= 1)==(j % 4 <= 1)) << " ";
puts("");
}
//printf("%d\n", res);
}
C. The Third Problem
Ideas :
res = The range that each number can transform
analysis :
01 The position of the cannot be changed ;
For the rest , Numbers less than this number are on one side of this number , Then this number cannot be moved ;
The rest can move , The active range is the interval composed of numbers smaller than this number ;
The code is as follows :
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false),cin.tie(0), cout.tie(0)
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e5 + 10, mod = 1e9 + 7;
int T;
void solve()
{
int n, m;
scanf("%d", &n);
int a[N] = {0}, p[N] = {0};
for(int i = 0; i < n; i ++ )
{
scanf("%d", &a[i]);
p[a[i]] = i;
}
int res = 1;
int l = p[0], r = p[0];
for(int i = 1; i < n; i ++ )
{
if(p[i] < l) l = p[i];
else if(p[i] > r) r = p[i];
else res = (LL)res*(r - l + 1 - i) % mod;
//cout << res << endl;
}
printf("%d\n", res);
//printf("%d\n", res);
}
int main()
{
//fast;
//cin >> T;
scanf("%d", &T);
while(T -- )
solve();
return 0;
}
边栏推荐
- 13. Model saving and loading
- 图像数据预处理
- Marubeni official website applet configuration tutorial is coming (with detailed steps)
- 新库上线 | 中国记者信息数据
- Interface test advanced interface script use - apipost (pre / post execution script)
- Thinkphp内核工单系统源码商业开源版 多用户+多客服+短信+邮件通知
- What has happened from server to cloud hosting?
- Malware detection method based on convolutional neural network
- Password recovery vulnerability of foreign public testing
- 第四期SFO销毁,Starfish OS如何对SFO价值赋能?
猜你喜欢
Y59. Chapter III kubernetes from entry to proficiency - continuous integration and deployment (III, II)
14.绘制网络模型结构
Codeforces Round #804 (Div. 2)(A~D)
Deep dive kotlin synergy (XXII): flow treatment
ThinkPHP kernel work order system source code commercial open source version multi user + multi customer service + SMS + email notification
Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布
Langchao Yunxi distributed database tracing (II) -- source code analysis
130. Zones environnantes
Password recovery vulnerability of foreign public testing
图像数据预处理
随机推荐
牛客基础语法必刷100题之基本类型
手机上炒股安全么?
Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布
Which securities company has a low, safe and reliable account opening commission
51 communicates with the Bluetooth module, and 51 drives the Bluetooth app to light up
德总理称乌不会获得“北约式”安全保障
ThinkPHP kernel work order system source code commercial open source version multi user + multi customer service + SMS + email notification
【愚公系列】2022年7月 Go教学课程 006-自动推导类型和输入输出
Codeforces Round #804 (Div. 2)
1. Linear regression
9.卷积神经网络介绍
swift获取url参数
German prime minister says Ukraine will not receive "NATO style" security guarantee
v-for遍历元素样式失效
基础篇——整合第三方技术
The method of server defense against DDoS, Hangzhou advanced anti DDoS IP section 103.219.39 x
ReentrantLock 公平锁源码 第0篇
股票开户免费办理佣金最低的券商,手机上开户安全吗
Implementation of adjacency table of SQLite database storage directory structure 2-construction of directory tree
ABAP ALV LVC template