当前位置:网站首页>Niuke Xiaobai monthly race 49
Niuke Xiaobai monthly race 49
2022-07-04 04:36:00 【Changersh】
A

Sign in
After reading the string , Convert bits into numbers ,%3 Output
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include<unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
const int N = 1e4 + 5;
const int MOD = 1e9 + 7;
char s[3], t[3];
int main() {
scanf("%s %s", s, t);
int a = s[0] - '0' + t[0] - '0';
a %= 3;
int b = s[1] - '0' + t[1] - '0';
b %= 3;
int c = s[2] - '0' + t[2] - '0';
c %= 3;
printf("%d%d%d", a, b, c);
return 0;
}
B


simulation
Now look , I feel it's troublesome to write
use s The array stores the gifts received and the corresponding colors ( Write too much , It leads to direct search , A waste of time , Should be assigned directly , Find it like this O(1))
Then I didn't input a color , Just judge once
Because color judgment is cumulative , It means that the last thing we input is 3 2 1 , Judge the first 3 when , Just find a gift with three , Judge the second 2 When , To statistics meanwhile There are color 3 and 2 A gift from
If a gift is in a certain color judgment , Not meeting the conditions , Just take the first one of the gift colors The assignment is 1, When traversing, judge whether to skip
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include<unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
const int N = 205;
const int MOD = 1e9 + 7;
int n, m;
int s[N][N];
void solve() {
scanf("%d %d", &n, &m);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
scanf("%d", &s[i][j]);
}
}
int a, cnt = 0;
for (int i = 0; i < m; i++) {
scanf("%d", &a);
for (int j = 0; j < n; j++) {
bool flag = false;
for (int k = 0; k < m; k++) {
if (s[j][0] == -1) break;
if (s[j][k] == a) {
cnt++, flag = true;
break;
}
}
if (flag == false) s[j][0] = -1;
}
printf("%d ", cnt);
cnt = 0;
}
printf("\n");
}
int main() {
int T;
scanf("%d", &T);
while (T--)
solve();
return 0;
}
Bucket row
vis[], The first i Item , Contains color …, This is a direct assignment ,O(1) lookup
judge[] It's No i Is the gift still qualified
b[] Receive the color to find
First traverse the color , Inner traversal gift , Judge gifts one by one , If b The color of the array , This gift has , And also meet the conditions , Just ans++
otherwise judge = 1, It means that the conditions are not met , After traversing a color, output it
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include<unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
const int N = 205;
const ll MOD = 1e9 + 7;
int n, m, a;
int vis[N][N]; // The first i Pieces of goods contain Color j
int judge[N]; // The first i Pieces of goods Whether the conditions are still met
int b[N];
void solve() {
memset(vis, 0, sizeof(vis));
memset(judge, 0, sizeof(judge));
memset(b, 0, sizeof(b));
scanf("%d %d", &n, &m);
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) {
scanf("%d", &a);
vis[i][a] = 1; // The first i Item , There are color a
}
for (int i = 0; i < m; i++) scanf("%d", &b[i]);
for (int j = 0; j < m; j++) {
int ans = 0;
for (int i = 0; i < n; i++) {
if (vis[i][b[j]]) {
if (!judge[i]) ans++;
}
else {
judge[i] = 1;
}
}
printf("%d%c", ans, (j == m - 1) ? '\n' : ' ');
}
}
int main() {
int T;
scanf("%d", &T);
while (T--)
solve();
return 0;
}
C


An operation + thinking
ai & aj ,& There are only two corresponding positions yes 1 When it comes to 1, therefore ,& The operation can only be original 1 The quantity remains the same , Or reduce , It's impossible to increase , therefore & The subsequent value must be less than or equal to ai and aj Of , And it is smaller than the smaller one of them
And then there is ,| operation , In fact Add 1 The operation of , Because one must be ai & ai Of , The result is ai, Everything else & value , It must be less than or equal to ai Of , all ai | Other values , The result is ai
therefore The final result is actually hold a1~an All the values XOR up 
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include<unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
const int N = 5e5 + 5;
const int MOD = 1e9 + 7;
int n, a[N];
long long res = 0;
void solve() {
scanf("%d", &n);
res = 0;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
res ^= a[i];
}
printf("%lld\n", res);
}
int main() {
int T;
scanf("%d", &T);
while (T--)
solve();
return 0;
}
D

Quadratic function image + Inverse element

From the quadratic function image, we can get , The maximum value is actually greater than 0 Part of ,S(b) - S(a)
Then cut off the quadratic function , Find the sum of each term separately , And then add it up 
Inverse element part , Generally, there are pits in division , There are decimals in division , But it's divisible , I made an appointment , The title does not say that it is a downward division , So divide —> Multiplication , Using the inverse element
Topic mod + 1 Then it happens to be divisible 2 and 6 Of , So you can write conveniently
iv2 = (MOD + 1) / 2ll;
iv6 = (MOD + 1) / 6ll;
Remember to take the mold ,ans and Output S(b) - S(a)
Sure add MOD Then take the mold , Prevent overflow ;
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include<unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
const int N = 1e4 + 5;
const ll MOD = 998244353;
const ll iv2 = (MOD + 1) / 2ll;
const ll iv6 = (MOD + 1) / 6ll;
ll a, b;
ll S(int t) {
ll ans1 = t * (t + 1ll) % MOD * (2ll * t + 1ll) % MOD * iv6 % MOD;
ll ans2 = (a + b) * t % MOD * (t + 1ll) % MOD * iv2 % MOD;
ll ans3 = a * b % MOD * t % MOD;
ll ans = -ans1 + ans2 - ans3;
ans = (ans % MOD + MOD) % MOD;
return ans;
}
void solve() {
scanf("%lld%lld", &a, &b);
printf("%lld\n", (S(b) - S(a) + MOD) % MOD);
}
int main() {
int T;
scanf("%d", &T);
while (T--)
solve();
return 0;
}
边栏推荐
- R语言dplyr中的Select函数变量列名
- B. All Distinct
- EventBridge 在 SaaS 企业集成领域的探索与实践
- 虚拟商品帐号交易平台源码_支持个人二维码收款
- Intersection traffic priority, illustration of intersection traffic rules
- Dp83848+ network cable hot plug
- [wechat applet] good looking carousel map component
- Architecture training graduation design + summary
- 普源DS1000Z系列数字示波器在通信原理实验中的应用方案
- Krypton saikr daily question - CTF
猜你喜欢
![[Yugong series] go teaching course 001 in July 2022 - Introduction to go language premise](/img/f2/3b95f53d67cd1d1979163910dbeeb8.png)
[Yugong series] go teaching course 001 in July 2022 - Introduction to go language premise

精品网址导航主题整站源码 wordpress模板 自适应手机端

分布式CAP理论

Emlog用户注册插件 价值80元

NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线

Redis: hash type data operation command

R语言中如何查看已安装的R包

Ppt tutorial, how to save a presentation as a PDF file in PowerPoint?

虚拟商品帐号交易平台源码_支持个人二维码收款

96% of the collected traffic is prevented by bubble mart of cloud hosting
随机推荐
EventBridge 在 SaaS 企业集成领域的探索与实践
【愚公系列】2022年7月 Go教学课程 001-Go语言前提简介
Detailed explanation of event cycle
最长递增子序列问题(你真的会了吗)
(pointeur) Écrivez - vous une fonction qui compare la taille de la chaîne et fonctionne comme strcmp.
6-4漏洞利用-SSH Banner信息获取
The interactive solution of JS and app in the H5 page embedded in app (parameters can be transferred and callbacks can be made)
Instructions for LPC interrupt binding under ft2000+
Ppt tutorial, how to save a presentation as a PDF file in PowerPoint?
R语言dplyr中的Select函数变量列名
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
Operation of ES6
Precautions for accompanying driving these 23 points should be paid attention to!
Redis: operation command for collecting set type data
I.MX6U-ALPHA开发板(C语言版本LED驱动实验)
Eig launched Grupo Cerro, a renewable energy platform in Chile
MySQL JDBC编程
普源DS1000Z系列数字示波器在通信原理实验中的应用方案
Leetcode brush question: binary tree 06 (symmetric binary tree)
Keysight n9320b RF spectrum analyzer solves tire pressure monitoring scheme