题解-ACM算法社国庆体验赛
代码模板
#include <bits/stdc++.h> #define endl '\n' #define int long long #define YES cout << "YES\n"; #define NO cout << "NO\n"; using namespace std; template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; } //void solve() {} signed main() { ios::sync_with_stdio(0); cin.tie(0); int t = 1; while (t--) solve(); return 0; }
B - 国庆的计划(简单)
// 模拟一个字符串数组即可。 void solve() { int n; vector<string> v = {"早八早起自律打CS2,冲击钻石S刻不容缓", "早八早起自律打永劫,冲击修罗刻不容缓", "早八早起自律打王者,冲击国服刻不容缓", "冲击强度太高,休息一天", "休息强度太高,再休息一天", "早八早起自律叫醒室友,冲击5-0 KD刻不容缓", "被0-5了,休息一天"}; cin >> n; cout << v[--n] << endl; }
C - 小高的加法
// 根据题意,奇偶数分开输出即可。 void solve() { int n; cin >> n; if (n % 2 == 0) cout << "114515\n191981" << endl; else cout << "114514\n191983" << endl; }
D - 两数之和
// 当 z 大于等于 3 时,总可以拆成 1 和 z-1 两个不同的正整数,否则无解。 void solve() { int n; cin >> n; if (n <= 2) { NO; } else { YES; cout << 1 << " " << n - 1 << endl; } }
E - 小龚的循环
// 循环输出递增的 rating,每轮输出后检查 rating 是否已达标 (>= n),若达标则立即终止循环。 void solve() { int n; cin >> n; for (int rating = 1999; ; rating += 5) { cout << rating << endl; if (rating >= n) break; } }
F - 小红出题
// 总题目数 = (完整周数 × 15) + (剩余天数中实际工作的天数 × 3)。 void solve() { int n; cin >> n; int ans = 0; ans += (n / 7) * 15; ans += min((n % 7) * 3, 15LL); cout << ans << endl; }
G - 小红的对错判断
// 将输入字符串全部转为小写,再判断是否等于 "yes" 即可。 void solve() { string s; cin >> s; for (char &c : s) { c = tolower(c); } if (s == "yes") { cout << "accept\n"; } else { cout << "wrong answer\n"; } }
H - 小红大战小紫
// 模拟题目即可。 void solve() { int a, b; cin >> a >> b; if (a < b) { cout << "yukari" << endl; } elif (a > b) { cout << "kou" << endl; } else { cout << "draw" << endl; } }
I - 小红的新周赛
// 直接求和即可。 void solve() { vector<int> v(6); cin >> v; cout << accumulate(all(v), 0LL) << endl; }