parent
8c4bafa02b
commit
d2b1beea5a
Binary file not shown.
@ -1,30 +1,30 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 110;
|
||||
|
||||
struct Node {
|
||||
int id;
|
||||
int score;
|
||||
const bool operator<(const Node &t) {
|
||||
if (score == t.score) return id < t.id;
|
||||
return score > t.score;
|
||||
const int N = 100010;
|
||||
vector<int> g[N];
|
||||
int c[N];
|
||||
int dfs(int u, int fa, int k) {
|
||||
if (k == 0) return c[u];
|
||||
int sum = c[u];
|
||||
for (int i = 0; i < g[u].size(); i++) {
|
||||
if (g[u][i] == fa) continue;
|
||||
sum += dfs(g[u][i], u, k - 1);
|
||||
}
|
||||
} a[N];
|
||||
/*
|
||||
3
|
||||
3 84
|
||||
1 87
|
||||
2 84
|
||||
*/
|
||||
return sum;
|
||||
}
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++) cin >> c[i];
|
||||
for (int i = 1; i < n; i++){
|
||||
int a, b;
|
||||
cin >> a >> b;
|
||||
g[a].push_back(b);
|
||||
g[b].push_back(a);
|
||||
}
|
||||
int k;
|
||||
cin >> k;
|
||||
for (int i = 1; i <= n; i++)
|
||||
cin >> a[i].id >> a[i].score;
|
||||
|
||||
sort(a + 1, a + 1 + n);
|
||||
|
||||
for (int i = 1; i <= n; i++)
|
||||
cout << a[i].id << " " << a[i].score << endl;
|
||||
cout << dfs(i, -1, k) << endl;
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 110;
|
||||
int a[N];
|
||||
int main() {
|
||||
cin >> a[0] >> a[1] >> a[2];
|
||||
sort(a, a + 3);
|
||||
cout << a[1] << endl;
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
bool isQm(int x) {
|
||||
int t = x;
|
||||
while (t) {
|
||||
int a = t % 10;
|
||||
if (a > 0 && x % a > 0) return false;
|
||||
t /= 10;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int n, m;
|
||||
cin >> n >> m;
|
||||
int cnt = 0;
|
||||
for (int i = n; i <= m; i++)
|
||||
if (isQm(i)) {
|
||||
cout << i << " ";
|
||||
cnt++;
|
||||
}
|
||||
if (cnt == 0) cout << -1;
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
|
||||

|
||||
|
||||
办法:将十六进制向十进制化,**而不是** 将十进制向十六进制转换。上来直接排除$D$(出题人不会太仁慈,否则就直接秒杀了),其它的靠算。
|
||||
|
||||

|
||||
```cpp {.line-numbers}
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 110;
|
||||
int a[N];
|
||||
int main() {
|
||||
cin >> a[0] >> a[1] >> a[2];
|
||||
sort(a, a + 3);
|
||||
cout << a[1] << endl;
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||

|
||||
```cpp {.line-numbers}
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
bool isQm(int x) {
|
||||
int t = x;
|
||||
while (t) {
|
||||
int a = t % 10;
|
||||
if (a > 0 && x % a > 0) return false;
|
||||
t /= 10;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int n, m;
|
||||
cin >> n >> m;
|
||||
int cnt = 0;
|
||||
for (int i = n; i <= m; i++)
|
||||
if (isQm(i)) {
|
||||
cout << i << " ";
|
||||
cnt++;
|
||||
}
|
||||
if (cnt == 0) cout << -1;
|
||||
return 0;
|
||||
}
|
||||
```
|
Loading…
Reference in new issue