codeforces
未读A.Make All Equal
题目描述
英文题面中文简义You are given a cyclic array $a_1,a_2,…,a_n$ .
You can perform the following operation on a at most $n−1$ times:
Let m be the current size of a, you can choose any two adjacent elements where the previous one is no greater than the latter one (In particular, $a_m$ and $a_1$ are adjacent and $a_m$ is the previous one), and delete exactly one of them. In other words, choose an integer i ( $1 \le i \le m$ ) where $a_i \le a_{(i \mod m)+1}$ holds, and delete exactly on ...
A Shout Everyday
题目
英文题面中文简义In the Kingdom of AtCoder, residents are required to shout their love for takoyaki at
A o’clock every day.
Takahashi, who lives in the Kingdom of AtCoder, goes to bed at
B o’clock and wakes up at C o’clock every day (in the 24-hour clock). He can shout his love for takoyaki when he is awake, but cannot when he is asleep. Determine whether he can shout his love for takoyaki every day. Here, a day has 24 hours, and his sleeping time is less than 24 hours.给定一个整数时间 A,一个人在 ...
建议查看中文题面,不要问为什么(问就是,英文题面就是复制过来的,中文体面精简些)
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() ...