CodeForces 518A Vitaly and Strings (水题,字符串)
题意:给定两个相同长度的字符串,让你找出一个字符串,字典序在两都之间。
析:这个题当时WA了好多次,后来才发现是这么水,我们只要把 s 串加上,然后和算数一样,该进位进位,然后再和 t 比较就行。
代码如下:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cstring>
#include <cmath>
#include <map>
#include <cctype> using namespace std;
const int maxn = 1000 + 5;
string s, t; int main(){
while(cin >> s >> t){
int n = s.size();
int cnt = 0;
++s[n-1];
if(s[n-1] > 'z'){ s[n-1] = 'a'; cnt = 1; }
for(int i = n-2; i >= 0; --i){
s[i] += cnt;
if(s[i] > 'z'){ s[i] = 'a'; cnt = 1; }
else cnt = 0;
}
if(s == t) puts("No such string");
else cout << s << endl; }
return 0;
}
CodeForces 518A Vitaly and Strings (水题,字符串)的更多相关文章
- codeforces 518A. Vitaly and Strings
A. Vitaly and Strings time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树
A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...
- codeforces 577B B. Modulo Sum(水题)
题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- codeforces 696A Lorenzo Von Matterhorn 水题
这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...
- CodeForces 589I Lottery (暴力,水题)
题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...
- Codeforces Gym 100286G Giant Screen 水题
Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...
- codeforces 710A A. King Moves(水题)
题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...
- codeforces 659A A. Round House(水题)
题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...
- CodeForces 489B BerSU Ball (水题 双指针)
B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input ...
随机推荐
- Apache 多网站配置
直接看实例就清楚了 Listen 80<VirtualHost *:80> DocumentRoot D:/Server/www ServerAdmin webmaster@lifashi ...
- 数据库比较工具DBCompareTool for Oracle 0.2.5发布
迁移数据库sql to oracle http://www.oracle.com/technetwork/cn/database/migration/connect-sqlserver-1945229 ...
- 微信小程序获取用户openid,头像昵称信息,后台java代码
https://blog.csdn.net/qq_39851704/article/details/79025557
- TNS-12535: TNS:operation timed out、TNS-00505: Operation timed out
在查看alert日志的时候发现: 1 *********************************************************************** 2 3 Fatal ...
- Hive 的查询结果直接导入到 MySQL 中的方法
步骤一: hive> add jar /setup/hive/lib/mysql-connector-java-5.1.25-bin.jar; hive> add jar /usr/lib ...
- 将Hive统计分析结果导入到MySQL数据库表中(一)——Sqoop导入方式
https://blog.csdn.net/niityzu/article/details/45190787 交通流的数据分析,需求是对于海量的城市交通数据,需要使用MapReduce清洗后导入到HB ...
- 七、配置ssh keys连通github跟ssh-agent
jenkins+github配置完成后,能够实现在提交pull request或者直接push时,能够将提交的代码拉去一份到服务器本地,并自动merge:但是代码拉去下来了,部署环境的时候却需要输入登 ...
- ES6系列_13之Proxy进行预处理(简单学习)
1.理解什么是预处理? 当我们在操作一个对象或者方法时会有几种动作,比如:在运行函数前初始化一些数据,在改变对象值后做一些善后处理.这些都算钩子函数,Proxy的存在就可以让我们给函数加上这样的钩子函 ...
- springboot 默认错误处理--自定义
1.在resoures下创建resoures/error文件夹 在其中自定义:404.html 403.html 500.html
- vba截屏保存
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVa ...