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