建议查看中文题面,不要问为什么(问就是,英文题面就是复制过来的,中文体面精简些)
A September
September
题目描述
英文题面中文题面There are $12$ strings $S_1, S_2, \ldots, S_{12}$ consisting of lowercase English letters.
Find how many integers $i$ $(1 \leq i \leq 12)$ satisfy that the length of $S_i$ is $i$.有 $12$ 个字符串 $S_1, S_2, S_3, \cdots S_{12}$
问有几个字符串满足 $S_{i} = i (1 \le i \le 12)$
太简单不需要解释
参考代码
#include<bits/stdc++.h>#define int long long#define endl '\n'#define pii std::pair<int ,int>#define fix(x) std::fixed <&l ...
codeforces
未读A. Robin Helps
Robin Helps
题目描述
英文题面中文简义There is a little bit of the outlaw in everyone, and a little bit of the hero too. The heroic outlaw Robin Hood is famous for taking from the rich and giving to the poor. Robin encounters n people starting from the 1\-st and ending with the n\-th. The i\-th person has ai gold. If ai≥k, Robin will take all ai gold, and if ai\=0, Robin will give 1 gold if he has any. Robin starts with 0 gold. Find out how many people Robin gives gold to.给定 $n$ 和 $k$ ,和一个长 ...
A TLD
题目描述
给定字符串s,输出字符串中.(点)后面的字符,若有多个.输出最后一个.的信息.
解题思路
有多种解法,可以暴力循环一次,或者用find()函数查找
参考代码
#include <bits/stdc++.h>#define int long long#define endl '\n'[[maybe_unused]]const int INF = 1e9 + 1;[[maybe_unused]] typedef std::pair<int, int> pii;void solve() { std::string s; std::cin >> s; int pos = 0, t = -1; while ((pos = s.find('.', pos)) != -1) t = pos, pos++; std::cout << s.substr(t + 1) << endl;}signed main() ...
A Capitalized?
题目描述
给定一个字符串s, 让我们判断是否满足首字母大写,其他字母小写的规则.
解题思路
直接用库函数islower()和isupper()模拟一下
参考代码
#include <bits/stdc++.h>//#define int long long#define endl '\n'[[maybe_unused]]const int INF = 2e18 + 50, MOD = 10007;[[maybe_unused]] typedef std::pair<int, int> pii;void solve() { std::string s; std::cin >> s; if (islower(s[0])) { std::cout << "No\n"; return; } for (int i = 1; i < s.size(); i++) if ...
A Tomorrow
题目大意
一年由 M个月组成,从 1月到 M月,每个月由 D天组成,从 1天到 D天。
问:在该日历中,年 y、月 m、日 d的下一天的日期?
参考代码
#include <bits/stdc++.h>#define int long long#define endl '\n'void solve(){ int M, D; std::cin >> M >> D; int y, m, d; std::cin >> y >> m >> d; d ++; if(d > D){ d -= D; m ++; if(m > M){ m -= M; y ++; } } std::cout << y << " " << m ...
A Wallet Exchange
题目大意
Alice有a个硬币,Bob有b个硬币,双方轮流进行以下操作:
1.与对方交换硬币,或者保留现有硬币.
2.取出一个硬币
无法进行操作的人判定为输,总是从Alice开始操作
问:哪位获得胜利
解题思路
我们可以把游戏看作是轮流取硬币,取得最后一个硬币的为胜利
那么我们就可以直接判断a+b奇偶性就可以得出答案.
代码
#include <bits/stdc++.h>#define int long long#define endl '\n'#define fix(n) std::fixed << std::setprecision(n)[[maybe_unused]]typedef std::pair<int, int> pii;[[maybe_unused]]const int INF = 1e18 + 50;void solve() { int a, b; std::cin >> a >> b; std::cout < ...
codeforces
未读A 2023
题目描述
给定 n个数,让我们判断是否能与 m个数相乘后可以得到 2023,并且将这些数输出出来
解题思路
我们只需要判断这些数能否被2023整除。
代码
#include <bits/stdc++.h>#define int long long#define endl '\n'#define fix(n) std::fixed << std::setprecision(n)[[maybe_unused]]typedef std::pair<int, int> pii;[[maybe_unused]]const int INF = 1e18 + 50;void solve() { int s = 2023; int n, m; std::cin >> n >> m; std::vector<int> a(n); for (int i = 0; i < n; i++) std::cin >> a[i]; for ...
A Strong Password
题目描述
给定字符串,现在让我们添加一个字符,使得字符串的价值最大,对于价值是这样看的
第一个字符的价值为2,
后面的字符若与前面的字符相同,则价值为1,否则价值为2。
让我们输出价值最大的一种情况
解题思路
我们可以遍历每一个位置,然后找出在哪个位置插入的价值最大,毕竟 n 的取值较小,最后再将其替换为与前后位置不相等的字符即可。
参考代码
#include<bits/stdc++.h>#define int long long#define endl '\n'#define pii std::pair<int ,int>#define fix(x) std::fixed << std::setprecision(x)const int inf = 1e17 + 50, MAX_N = 1e5 + 50, mod = 1e9 + 7;void solve () { std::string s, t; std::cin >> s; if(s.size() ...
A Tricky Template
题目描述
给一个数字n和三个长度为n的字符串 a,b,c。找一个模板使得字符串a,b匹配,而c不匹配,是否存在这样一个模板.
匹配的定义是:当模板字母为小写时,两个字符串字符相同,为大写时,两个字符不同,这样的两个字符串则匹配
解题思路
我们可以直接得出当a字符串和b字符串都不等于c字符串时,就存在这样一个模板使得满足题意
参考代码
#include <bits/stdc++.h>#define int long long#define endl '\n'[[maybe_unused]]const int INF = 1e18 + 50, pi = 3;[[maybe_unused]]typedef std::pair<int, int> pii;void solve() { int n; std::cin >> n; std::string a, b, c; std::cin >> a >> b >> c; f ...
A Rating Increas
题目大意
给定一个数字,让我们拆分成两个数,这两个数满足以下条件:
a < b.
两个数没有前缀0.
问:输出满足条件的数a , b.
解题思路
直接暴力循环这个数的位数次,若满足a < b,再判断两个数的位数和是否与拆分前相同.
代码
#include <bits/stdc++.h>#define int long long#define endl '\n'void solve() { int n, cnt = 1, k = 0; std::cin >> n; int s = n; while (s) { k++; s /= 10; } int t = k; while (k--) { int w = n; int a = w / cnt, b = w % cnt; int x = a, y = b; int s1 = ...