#include <iostream>
using namespace std;
int main() {
int x, y, n;
cin >> x >> y >> n;
if (n >= x + y) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
B.放课后故事
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m, k;
cin >> n >> m >> k;
vector<long long> paper(n);
long long num = 0;
for(long long i = 0; i < n; ++i) {
cin >> paper[i];
num += paper[i];
}
long long planes = num / k;
planes = min(planes, m+1);
cout << planes << endl;
return 0;
}
C.异或故事
#include <bits/stdc++.h>
using namespace std;
void solve() {
int a;
cin >> a;
if (a == 1) {
cout << "2 3" << '\n';
}
else if (a == 1e9) {
cout << 999999999 << ' ' << 1023 << '\n';
}
else {
cout << 1 << ' ' << (1 ^ a) << '\n';
}
}
signed main() {
long long t = 1;
cin >> t;
while (t--) {
solve();
}
}
D.构造故事
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
vector<long long> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
sort(a.begin(), a.end(), greater<long long>()); // 降序排序
long long maxPerimeter = -1;
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
for (int k = j + 1; k < n; ++k) {
if (a[i] < a[j] + a[k]) { // 检查是否满足三角形条件
maxPerimeter = max(maxPerimeter, a[i] + a[j] + a[k]);
goto found; // 找到后直接跳出所有循环
}
}
}
}
found: // 标签用于在找到后立即跳出所有循环
cout << maxPerimeter << endl;
}
return 0;
}