当前位置:网站首页>Niuke Xiaobai month race 52
Niuke Xiaobai month race 52
2022-06-30 08:01:00 【Chao Tang】
Niuke Xiaobai moon race 52
Problem A
Discuss and judge directly ,7 Point every time to , Eight o'clock 1 branch ~5 Minute late , Other absenteeism .
Problem B
simulation , Press 10 The rule of digits is to try whether it can be carried . Notice when you see 5000 Can be carried into 10000 .
Problem C
Prefix and maintenance interval are accumulated , Finally, see which part has the least accumulation times , At this time, when all the other instructions except this instruction are wrong, the number of wrong instructions is the most .
Problem D
Tree array & ST surface
A round table , So we should increase to 2 times . The value indicated by the question can only take one arc at a time ( It can also be a whole circle ), Start with each cake , Use two points to find out which cake you can eat when you are full , And then use ST Table find the maximum value of cream in this range . Time complexity O ( n log n ) O(n\log n) O(nlogn)
This method has gone too far , But I was a little puzzled when I was writing the solution to the question , It seems that such enumeration can not guarantee that the cream group with the highest and lowest amount of cream does not include other higher cream ? It seems that I can't express myself clearly .
Problem E
At first, I thought about balancing numbers , Copy a template and WA 了 , Because the contribution of the elements of the group added later is not considered .
The positive solution of the problem is : Two points of addition and exclusion
Find out the contribution of demand value in all numbers , Then subtract the contribution of demand value in this group .
Problem F
Pack in groups , Didn't do it .
Code:
Problem A
// Good Good Study, Day Day AC.
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <map>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define ffor(i,a,b) for(int i=(a) ;i<=(b) ;i++)
#define rrep(i,a,b) for(int i=(a) ;i>=(b) ;i--)
#define mst(v,s) memset(v,s,sizeof(v))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define ll long long
#define INF 0x7f7f7f7f7f7f7f7f
#define inf 0x7f7f7f7f
#define PII pair<int,int>
#define int long long
using namespace std;
int n, T = 1;
void ready()
{
int a = 0, b = 0;
cin >> n;
while (n--) {
string st;
cin >> st;
if (st[0] == '7') continue;
if (st[0] == '9') b++;
if (st[0] == '8') {
int t = (st[2] - '0') * 10 + st[3] - '0';
if (t <= 5 && t != 0) a++;
else if (t > 5) b++;
}
}
cout << a << ' ' << b << '\n';
}
void work()
{
}
signed main()
{
IOS;
cin>>T;
while (T--) {
ready();
work();
}
return 0;
}
Problem B
// Good Good Study, Day Day AC.
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <map>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define ffor(i,a,b) for(int i=(a) ;i<=(b) ;i++)
#define rrep(i,a,b) for(int i=(a) ;i>=(b) ;i--)
#define mst(v,s) memset(v,s,sizeof(v))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define ll long long
#define INF 0x7f7f7f7f7f7f7f7f
#define inf 0x7f7f7f7f
#define PII pair<int,int>
#define int long long
using namespace std;
int n, T = 1;
void ready()
{
cin >> n;
}
void work()
{
int t = 1, ans = n;
if (ans < 10) {
if (ans >= 5) ans = 10;
}
while (n >= t) {
t *= 10;
int b = n % t;
if (b >= 10) while (b >= 10) b = b / 10;
n = n / t * t;
if (b >= 5) n += t;
//cout << "b=" << b << '\n';
ans = max(ans, n);
//cout << "n= " <<n<< '\n';
//cout << "t=" << t << '\n'<<'\n';
}
cout << ans << '\n';
}
signed main()
{
IOS;
cin>>T;
while (T--) {
ready();
work();
}
return 0;
}
Problem C
// Good Good Study, Day Day AC.
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <map>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define ffor(i,a,b) for(int i=(a) ;i<=(b) ;i++)
#define rrep(i,a,b) for(int i=(a) ;i>=(b) ;i--)
#define mst(v,s) memset(v,s,sizeof(v))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define ll long long
#define INF 0x7f7f7f7f7f7f7f7f
#define inf 0x7f7f7f7f
#define PII pair<int,int>
#define int long long
using namespace std;
const int N = 1e6 + 6;
int n, T = 1, m;
int sum[N];
void ready()
{
cin >> n >> m;
ffor(i,1,m) {
int op, x, y;
cin >> op;
if (op == 1) {
cin >> x >> y;
sum[x]++; sum[y + 1]--;
}
if (op == 2) {
cin >> x;
sum[x]++;
}
if (op == 3) {
cin >> x;
sum[1]++; sum[x+1]--;
}
}
int ans = inf, cnt = 0;
ffor(i, 1, n) {
sum[i] += sum[i - 1];
ans = min(sum[i], ans);
}
// ffor(i, 1, n) cout << sum[i] << ' '; cout << '\n';
cout << m - ans << ' ';
ffor(i, 1, n) {
if (sum[i] == ans) {
cnt++;
// cout << "i=" << i << '\n';
}
}
cout << cnt;
}
void work()
{
}
signed main()
{
IOS;
// cin>>T;
while (T--) {
ready();
work();
}
return 0;
}
Problem D
// Good Good Study, Day Day AC.
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <map>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define ffor(i,a,b) for(int i=(a) ;i<=(b) ;i++)
#define rrep(i,a,b) for(int i=(a) ;i>=(b) ;i--)
#define mst(v,s) memset(v,s,sizeof(v))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define ll long long
#define INF 0x7f7f7f7f7f7f7f7f
#define inf 0x7f7f7f7f
#define PII pair<int,int>
#define int long long
using namespace std;
const int N = 1e6 + 5;;
int n, T = 1, s;
int b[N], d[N][22];
int lowbite(int x)
{
return x & (-x);
}
void add_in(int i, int num, int c[])
{
while (i <= n * 2)
{
c[i] += num;
i += lowbite(i);
}
return;
}
int get_sum(int x, int c[])
{
int sum = 0;
while (x)
{
sum += c[x];
x -= lowbite(x);
}
return sum;
}
void ready()
{
cin >> n >> s;
ffor(i, 1, n) {
int bi;
cin >> bi;
add_in(i, bi, b);
add_in(i + n, bi, b);
}
ffor(i, 1, n) {
int di;
cin >> di;
d[i][0] = d[n + i][0] = di;
}
ffor(j, 1, 19) {
ffor(i, 1, 2 * n) {
d[i][j] = max(d[i][j - 1], d[i + (1 << (j - 1))][j - 1]);
}
}
}
int get_max(int x, int y)
{
int mid = log2(y - x + 1);
return max(d[x][mid], d[y - (1 << mid) + 1][mid]);
}
void work()
{
if (get_sum(n, b) < s) {
cout << -1;
return;
}
int ans = inf;
for (int i = 1; i <= n; i++) {
int l = i, r = n + i - 1, mid;
while (l < r) {
mid = l + r >> 1;
if (get_sum(mid, b) - get_sum(i - 1, b) < s) l = mid + 1;
else r = mid;
}
ans = min(ans, get_max(i, l));
}
cout << ans;
}
signed main()
{
IOS;
// cin>>T;
while (T--) {
ready();
work();
}
return 0;
}
Problem E
// Good Good Study, Day Day AC.
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <map>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define ffor(i,a,b) for(int i=(a) ;i<=(b) ;i++)
#define rrep(i,a,b) for(int i=(a) ;i>=(b) ;i--)
#define mst(v,s) memset(v,s,sizeof(v))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define ll long long
#define INF 0x7f7f7f7f7f7f7f7f
#define inf 0x7f7f7f7f
#define PII pair<int,int>
#define int long long
using namespace std;
const int N = 1e6 + 6;
const int mod = 998244353;
int n, T = 1, k;
vector<int> ve[N], alls;
void ready()
{
cin >> n >> k;
ffor(i, 1, n) {
int s;
cin >> s;
ffor(j, 1, s) {
int x;
cin >> x;
alls.push_back(x);
ve[i].push_back(x);
}
sort(ve[i].begin(), ve[i].end());
}
sort(alls.begin(), alls.end());
}
void work()
{
int ans = 0;
ffor(i, 1, n) {
for (auto item : ve[i]) {
int x = k - item;
ans += (alls.end() - lower_bound(alls.begin(), alls.end(), x)) - (ve[i].end() - lower_bound(ve[i].begin(), ve[i].end(), x));
}
}
ans /= 2;
cout << ans % mod;
}
signed main()
{
IOS;
// cin>>T;
while (T--) {
ready();
work();
}
return 0;
}
边栏推荐
- [flower carving experience] 14 line blank board pingpong library test external sensor module (one)
- 1162 Postfix Expression
- Palindrome substring, palindrome subsequence
- Why don't you know what to do after graduation from university?
- 深度学习——语言模型和序列生成
- 【笔记】Polygon mesh processing 学习笔记(10)
- MySQL加索引语句不加锁:ALGORITHM=INPLACE, LOCK=NONE
- 1163 Dijkstra Sequence
- [notes] polygon mesh processing learning notes (10)
- Deep learning -- sequence model and mathematical symbols
猜你喜欢

CRM能为企业带来哪些管理提升

期末複習-PHP學習筆記5-PHP數組
![November 22, 2021 [reading notes] - bioinformatics and functional genomics (Chapter 5, section 4, hidden Markov model)](/img/0d/77953ffa9f45a5acc16f02bf33293b.jpg)
November 22, 2021 [reading notes] - bioinformatics and functional genomics (Chapter 5, section 4, hidden Markov model)

Acreems energy efficiency management platform escorts the power safety of high-rise residential areas

Analysis of cross clock transmission in tinyriscv

25岁,从天坑行业提桶跑路,在经历千辛万苦转行程序员,属于我的春天终于来了

Development technology sharing of Jingtan NFT digital collection system
![February 14, 2022 [reading notes] - life science based on deep learning Chapter 2 Introduction to deep learning (Part 1)](/img/ff/e4df5a66cda74ee0d71015b7d1a462.jpg)
February 14, 2022 [reading notes] - life science based on deep learning Chapter 2 Introduction to deep learning (Part 1)

Deep learning -- language model and sequence generation

Simple application of generating function -- integer splitting 2
随机推荐
深度学习——词汇表征
你了解IP协议吗?
Deep learning vocabulary representation
1163 Dijkstra Sequence
February 14, 2022 [reading notes] - life science based on deep learning Chapter 2 Introduction to deep learning (Part 1)
Xiashuo think tank: 42 reports on planet update today (including 23 planning cases)
Summary and common applications of direction and angle operators in Halcon
Combinatorial mathematics Chapter 2 Notes
Deep learning -- using word embedding and word embedding features
December 19, 2021 [reading notes] - bioinformatics and functional genomics (Chapter 5 advanced database search)
Final review -php learning notes 8-mysql database
MySQL加索引语句不加锁:ALGORITHM=INPLACE, LOCK=NONE
Deep learning -- feature point detection and target detection
深度学习——BRNN和DRNN
深度学习——嵌入矩阵and学习词嵌入andWord2Vec
多快好省,低门槛AI部署工具FastDeploy测试版来了!
Projection point of point on line
JS代码案例
Recurrence relation (difference equation) -- Hanoi problem
【笔记】Polygon mesh processing 学习笔记(10)