## 牛客小白月赛55 A-E

news/2024/8/6 16:25:36/文章来源:https://www.cnblogs.com/CTing/p/16606997.html

# 牛客小白月赛55 A-E

https://ac.nowcoder.com/acm/contest/38630

F待补

## A - 至至子的等差中项

``````#include <bits/stdc++.h>using namespace std;int main () {int a, b;cin >> a >> b;cout << 2*b-a;
}
``````

## B - 至至子的按位与

``````#include <bits/stdc++.h>
#define int long longusing namespace std;
int a, b;void solve () {cin >> a >> b;int maxn = (1ll << 63) - 1ll;cout << maxn - (a ^ b) << endl;
}signed main () {solve ();
}
``````

## C - 至至子的斐波那契

``````#include <bits/stdc++.h>
#define int long longusing namespace std;
vector <int> v;void pre () {v.push_back (0), v.push_back (1), v.push_back (1);int x = 0;for (int i = 3; x <= 1e18; i++) {x = v[i-1] + v[i-2];v.push_back (x);}//for (auto i : v)    cout << i << ", ";
}void solve () {int n, i;cin >> n;for (i = 1; ; i++) {if (v[i] >= n)  break;}if (v[i] - n >= n - v[i-1])  cout << i-1;else cout << i;cout << endl;
}signed main () {pre ();int t;cin >> t;while (t --) {solve ();}
}
``````

## D - 至至子的鸿门宴

``````#include <bits/stdc++.h>
#define int long longusing namespace std;
const int N = 1e6 + 5;
int n, a[N];signed main () {cin >> n;int sum = 0;for (int i = 1; i <= n; i++) {cin >> a[i];sum += a[i] - i;}// b[1] = a[1];// for (int i = 1; i <= n; i++)    b[i] --, sum += b[i];//cout << sum << endl;if (sum % 2 == 0)   puts ("SSZ");else    puts ("ZZZ");}
``````

## E - 至至子的长链剖分

``````#include <bits/stdc++.h>
#define int long longusing namespace std;
typedef pair<int, int> pii;
const int N = 2e5 + 5;
int n;void solve () {cin >> n;vector <int> cnt[n+1]; //pre cntint maxn = 0, x;for (int i = 1; i <= n; i++) {cin >> x;cnt[x].push_back (i);maxn = max (maxn, x);}// for (int i = 0; i <= n; i++) {//     if (cnt[i].size() == 0) continue;//     cout << "i= " << i << ", ";//     for (auto j : cnt[i])//         cout << j << ' ';//     cout << endl;// }if (n == 1) {if (x)    cout << -1 << endl;else    cout << 1 << endl;return ;}if (cnt[maxn].size() > 1 || cnt[0].size() == 0)  {cout << -1 << endl;return ;}vector <pii> ans;for (int i = 1; i <= maxn; i++) {if (cnt[i].size() == 0 || cnt[i].size() > cnt[i-1].size()) {cout << "-1\n";return ;}int cnt1 = cnt[i-1].size(), cnt2 = cnt[i].size();for (int j = 0; j < cnt2; j++)  ans.push_back ({cnt[i-1][j], cnt[i][j]});for (int j = cnt2; j < cnt1; j++)   ans.push_back ({cnt[i-1][j], cnt[i][0]});}cout << cnt[maxn][0] << endl;for (auto i : ans)  cout << i.first << ' ' << i.second << endl;}signed main () {int t;cin >> t;while (t --) {solve ();}
}//h为几就在第几+1层(从下往上)
//相邻数字连一条边
//并且上层的个数一定要小于等于下层的//之前是把所有的都连到一点上所以就错了
//上一层与下一层尽量相连，然后多的在统一连到一点
``````

## F - 至至子的公司排队

### redis（2）

redis的简单抽象模型：文件事件处理器===>保证redis单线程多个socket ------->>>service socket 请求--->>------->>>io多路复用程序------->>>队列------->>>文件处理分派器------->>>各种事件处理器：1.事件请求处理器…

### 听GPT 讲Rust源代码--src/tools(14)

File: rust/src/tools/rust-analyzer/crates/cfg/src/lib.rs 在Rust源代码中&#xff0c;rust/src/tools/rust-analyzer/crates/cfg/src/lib.rs这个文件是Rust语言分析器&#xff08;Rust Analyzer&#xff09;的一部分&#xff0c;用于处理和管理条件编译指令&#xff08;Cond…

### 视频推拉流平台EasyDSS点播文件播放请求添加token验证的实现方法

EasyDSS视频直播点播平台可提供一站式的视频推拉流、转码、点播、直播、播放H.265编码视频等服务&#xff0c;搭配RTMP高清摄像头使用&#xff0c;可将设备的实时流推送到平台上&#xff0c;实现无人机视频推流直播等应用。今天我们来介绍下EasyDSS系统点播文件播放请求添加tok…

### 1846_安全SPI

Grey 全部学习内容汇总&#xff1a;GitHub - GreyZhang/g_embedded: some embedded basic knowledge. 1846_安全SPI SPI是一种常见的通信方式&#xff0c;在汽车电子中比较常用。但是如果涉及到安全相关的设计&#xff0c;可能得考虑更多。而SPI协议本身没有很好的标准化&am…