'commit'
10
TangDou/LanQiaoBei/LanQiao13STEMA202210/1.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
typedef long long LL;
|
||||
int main() {
|
||||
LL n;
|
||||
scanf("%lld", &n);
|
||||
printf("%lld", n - 1);
|
||||
return 0;
|
||||
}
|
||||
12
TangDou/LanQiaoBei/LanQiao13STEMA202210/2.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
char c;
|
||||
int n;
|
||||
scanf("%c %d", &c, &n);
|
||||
if (c + n > 'z') printf("*");
|
||||
else printf("%c", c + n);
|
||||
return 0;
|
||||
}
|
||||
26
TangDou/LanQiaoBei/LanQiao13STEMA202210/3.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
const int N = 2000;
|
||||
/*
|
||||
4
|
||||
-1 3 5 3
|
||||
3
|
||||
*/
|
||||
int a[N];
|
||||
int k, n, x;
|
||||
int main() {
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++) cin >> a[i];
|
||||
cin >> x;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
if (a[i] == x) {
|
||||
k = i;
|
||||
printf("%d", k);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (k == 0)
|
||||
printf("-1");
|
||||
return 0;
|
||||
}
|
||||
43
TangDou/LanQiaoBei/LanQiao13STEMA202210/4.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct Node {
|
||||
int num;
|
||||
int step;
|
||||
};
|
||||
|
||||
const int N = 1010;
|
||||
int n, m;
|
||||
queue<Node> q;
|
||||
int st[N];
|
||||
|
||||
void bfs() {
|
||||
q.push({n, 0});
|
||||
while (q.size()) {
|
||||
auto x = q.front();
|
||||
q.pop();
|
||||
if (x.num == m) {
|
||||
printf("%d\n", x.step);
|
||||
break;
|
||||
}
|
||||
if (!st[x.num + 1]) {
|
||||
q.push({x.num + 1, x.step + 1});
|
||||
st[x.num + 1] = 1;
|
||||
}
|
||||
if (!st[x.num - 1]) {
|
||||
q.push({x.num - 1, x.step + 1});
|
||||
st[x.num - 1] = 1;
|
||||
}
|
||||
if (!st[x.num * 2]) {
|
||||
q.push({x.num * 2, x.step + 1});
|
||||
st[x.num * 2] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin >> n >> m;
|
||||
bfs();
|
||||
return 0;
|
||||
}
|
||||
37
TangDou/LanQiaoBei/LanQiao13STEMA202210/5_1.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
// OJ地址
|
||||
// https://www.acwing.com/problem/content/150/
|
||||
|
||||
// 黄海题解
|
||||
// https://www.cnblogs.com/littlehb/p/15488791.html
|
||||
|
||||
//小顶堆
|
||||
priority_queue<int, vector<int>, greater<int>> q;
|
||||
|
||||
int res;
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
|
||||
while (n--) {
|
||||
int x;
|
||||
cin >> x;
|
||||
q.push(x);
|
||||
}
|
||||
|
||||
while (q.size() > 1) {
|
||||
int a = q.top();
|
||||
q.pop();
|
||||
int b = q.top();
|
||||
q.pop();
|
||||
res += a + b;
|
||||
q.push(a + b);
|
||||
}
|
||||
|
||||
printf("%d\n", res);
|
||||
return 0;
|
||||
}
|
||||
29
TangDou/LanQiaoBei/LanQiao13STEMA202210/5_2.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <iostream>
|
||||
#include <queue>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
priority_queue<int> q;
|
||||
while (n--) {
|
||||
int x;
|
||||
cin >> x;
|
||||
q.push(-x);
|
||||
}
|
||||
|
||||
int res = 0;
|
||||
while (q.size() > 1) {
|
||||
int a = q.top();
|
||||
q.pop();
|
||||
int b = q.top();
|
||||
q.pop();
|
||||
|
||||
res -= a + b;
|
||||
q.push(a + b);
|
||||
}
|
||||
|
||||
printf("%d\n", res);
|
||||
return 0;
|
||||
}
|
||||
25
TangDou/LanQiaoBei/LanQiao13STEMA202210/TD.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
priority_queue<int, vector<int>, greater<int>> q;
|
||||
|
||||
int res;
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
while (n) {
|
||||
int x;
|
||||
cin >> x;
|
||||
q.push(x);
|
||||
}
|
||||
while (q.size() > 1) {
|
||||
int a = q.top();
|
||||
q.pop();
|
||||
int b = q.top();
|
||||
q.pop();
|
||||
res += a + b;
|
||||
q.push(a + b);
|
||||
}
|
||||
printf("%d", res);
|
||||
return 0;
|
||||
}
|
||||
BIN
TangDou/LanQiaoBei/LanQiao13STEMA202210/编程题/1.jpg
Normal file
|
After Width: | Height: | Size: 70 KiB |
BIN
TangDou/LanQiaoBei/LanQiao13STEMA202210/编程题/2.jpg
Normal file
|
After Width: | Height: | Size: 104 KiB |
BIN
TangDou/LanQiaoBei/LanQiao13STEMA202210/编程题/3.jpg
Normal file
|
After Width: | Height: | Size: 132 KiB |
BIN
TangDou/LanQiaoBei/LanQiao13STEMA202210/编程题/4.jpg
Normal file
|
After Width: | Height: | Size: 171 KiB |
BIN
TangDou/LanQiaoBei/LanQiao13STEMA202210/编程题/5_1.jpg
Normal file
|
After Width: | Height: | Size: 113 KiB |
BIN
TangDou/LanQiaoBei/LanQiao13STEMA202210/编程题/5_2.jpg
Normal file
|
After Width: | Height: | Size: 85 KiB |
BIN
TangDou/LanQiaoBei/LanQiao13STEMA202210/编程题/5_3.jpg
Normal file
|
After Width: | Height: | Size: 58 KiB |