[链接]:CF [代码]: #include<bits/stdc++.h> #define PI acos(-1.0) #define pb push_back #define F first #define S second #define debug puts #define setp cout << fixed << setprecision(3) #define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cou…
B - Reversing Encryption A string s of length n can be encrypted by the following algorithm: iterate over all divisors of n in decreasing order (i.e. from n to 1), for each divisor d, reverse the substring s[1-d] (i.e. the substring which starts at p…
#include <iostream> #include <string> #include <algorithm> #include <cstring> inline void STL_Reverse(std::string& str) // 反转string字符串 包装STL的reverse() 可以inline { reverse(str.begin(), str.end()); // STL 反转函数 reverse() 的实现 /* tem…
Given an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky the". Update (2015-02-12):For C programmers: Try to solve it in-place in O(1) space. click to show clarification. Clari…
problem: Given an input string, reverse the string word by word. For example: Given s = "the sky is blue", return "blue is sky the". 问题分析:如何准确的找到每一个需要清除的空格的位置pos,以及每个word对应的pos范围? 解决方法:需要反转一个字符串,使用int string.find_last_not_of(char c, in…
A string ss of length nn can be encrypted(加密) by the following algorithm: iterate(迭代) over all divisors(除数) of nn in decreasing order (i.e. from nn to 11), for each divisor dd, reverse the substring s[1…d]s[1…d] (i.e. the substring which starts at po…
Soldier and Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Two bored soldiers are playing card war. Their card deck consists of exactly n cards, numbered from 1 to n, all values are…
string [描述] 给定两个字符串 s,t,其中 s 只包含小写字母以及*,t 只包含小写字母. 你可以进行任意多次操作,每次选择 s 中的一个*,将它修改为任意多个(可以是 0 个)它的前一个字符.问是否能将 s 修改为 t. 有多组数据. [输入] 第一行一个整数 T 表示数据组数. 每组数据两行,第一行一个字符串 s,第二行一个字符串 t. [输出] 每组数据输出一行,如果能将 s 修改为 t,输出 Yes,否则输出 No. [输入样例] 2 a* aaaa a* ab [输出样例]…
题目描述 小$G$有一个长度为$n$的$01$串$T$,其中只有$T_S=1$,其余位置都是$0$.现在小$G$可以进行若干次以下操作: $\bullet$选择一个长度为K的连续子串($K$是给定的常数),翻转这个子串. 对于每个$i,i\in[1,n]$,小$G$想知道最少要进行多少次操作使得$T_i=1$.特别的,有$m$个“禁止位置”,你需要保证在操作过程中$1$始终不在任何一个禁止位置上. 输入格式 从文件$reverse.in$中读入数据. 第一行四个整数$n,K,m,S$. 接下来一…
题目传送门(内部题56) 输入格式 第一行包含一个整数:$T$,表示数据组数.接下来$T$行,每行包含两个字符串:$a\ b$. 输出格式 对于每组数据,如果存在$c$,输出最长的情况下字典序最大的$c$,否则输出$-1$. 样例 样例输入: 3AB BAABA BABAB ABAA 样例输出: -1ABAB 数据范围与提示 样例解释: 对于第一组数据,不存在这样的$c$.对于第二组数据,$AB$以通过第一种操作到$ABA$,$AB$可以通过第二种操作到$BAB$.对于第三组数据,$AB$不需要…