雅礼2023.12.27习题课有哪些重点内容讲解?
摘要:雅礼 2023.12.27 习题课记录 前言 这一场罚时多,都是一些低级错误。 好吧全都是水题。 水题(只放代码) 莫诺卡普参加了一场编程比赛,其中包括 (26) 个问题,从 A 到 Z 命名。问题按难度排序。此外,已知莫诺卡普可以在
雅礼 2023.12.27 习题课记录
前言
这一场罚时多,都是一些低级错误。
好吧全都是水题。
水题(只放代码)
莫诺卡普参加了一场编程比赛,其中包括 \(26\) 个问题,从 A 到 Z 命名。问题按难度排序。此外,已知莫诺卡普可以在 \(1\) 分钟内解决问题 A,在 \(2\) 分钟内解决问题 B,\(\dots\),在 \(26\) 分钟内解决问题 Z。比赛结束后,你发现了他的比赛记录 - 一个由大写拉丁字母组成的字符串,其中第 \(i\) 个字母表示莫诺卡普在比赛的第 \(i\) 分钟时正在解决的问题。如果莫诺卡普总共花费了足够的时间来解决一个问题,他就解决了它。请计算莫诺卡普在比赛期间解决的问题数量。
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
using namespace std;
using ll = long long;
#define mtest for (cin >> t; t; -- t)
const int kMaxN = 1e5 + 10, kInf = (((1 << 30) - 1) << 1) + 1;
const ll kLInf = 9.22e18;
int n;
string s;
int a[kMaxN];
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t;
mtest {
for (int i = 1; i <= 26; ++ i) {
a[i] = 0;
}
cin >> n >> s;
for (int i = 0; i < s.size(); ++ i) {
++ a[s[i] - 'A' + 1];
}
int ans = 0;
for (int i = 1; i <= 26; ++ i) {
if (a[i] >= i) {
++ ans;
}
}
cout << ans << '\n';
}
return 0;
}
C - Preparing for the Contest(CF1914B)
输出一个长度为 \(n\) 的序列,使序列中后一个数比前一个数大的次数为 \(k\)。
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
using namespace std;
using ll = long long;
#define mtest for (cin >> t; t; -- t)
const int kMaxN = 1e5 + 10, kInf = (((1 << 30) - 1) << 1) + 1;
const ll kLInf = 9.22e18;
int n, k;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t;
mtest {
cin >> n >> k;
for (int i = 1; i <= (!k? 0 : k); ++ i) {
cout << i << ' ';
}
int ans = 1;
for (int i = n; ans <= (!k? n : n - k); -- i) {
cout << i << ' ';
++ ans;
}
cout << '\n';
}
return 0;
}
E - Rating Increase(CF1913A)
给定 \(\overline{ab}\),求任意一种可能的 \(a,b\),其中 \(0<a<b\) 且 \(a,b\) 无前导零。
