tantan的博客

Notes, ideas, and observations

Bash基本使用

#常用快捷键

#题意

  1. 将N个人按照身高排成K行
  2. 每行N/K个人,
  3. 后排的人比前排的人高
  4. 每一排之中, 最高的人在中间, 然后依次在左,右排列
  5. 相同身高的人按字典序排列

考试结束

假期的一些计划

#近期任务

  • 内存数据库最终项目
  • 计算机网络实验报告

寻找{(x,y)|x+y=m,x,y∈S}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <unordered_map>
using namespace std;

int main()
{
int n, m;
cin >> n >> m;
unordered_map<int, int> S;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
S[x]++;
}

int minx = 0;
for (auto &&k : S) {
int x = k.first;
int y = m - x;
if (x < y && S.find(y) != S.end() || x == y && S[x] > 1) {
if (!minx || x < minx)
minx = x;
}
}
if (minx) {
cout << minx << " " << m - minx << endl;
} else {
cout << "No Solution" << endl;
}
return 0;
}

找规律题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Solution {
public:
vector<bool> prefixesDivBy5(vector<int>& A) {
vector<bool> ret;
int res = 0;
for(auto&&a:A){
res = res * 2 + a;
res %= 10;
if(res % 5 == 0){
ret.push_back(true);
}else{
ret.push_back(false);
}
}
return ret;
}
};
0%