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 ...
随机推荐
- FastAdmin 升级后出现 is already in use
FastAdmin 升级后出现 is already in use 升级 FastAdmin 改进很多,但全新安装出现以下错误 Cannot use app\common\library\Menu a ...
- Mplayer1.0rc2移植到am335x开发板
因项目需要媒体播放器,所以准备使用QT+Mplayer来做,但遇到了屏幕闪烁的问题,无法满足需求. 1.参考<mplayer 移植到 arm 心得> ,http://blog.csdn.n ...
- (判断)window.open()窗口被关闭后执行事件
$(function() { // start ready var $article_share=$('#body .article').find('li.share'); // $article_s ...
- emacs之配置php
php-setting.el (require 'php-mode) 以后丰富
- java 输出helloword
1,安装jdk;2,配置环境变量;3,新建D:/Test.java文件;4,文件内容如下:public class Test{ public static void main(String[] arg ...
- servlet的登陆案例
Users.java package com.po; public class Users { private String username; private String password; pu ...
- 使用Javamail发送邮件Util
maven: <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artif ...
- apache配置https和http的时候You don't have permission to access / on this server.
You don't have permission to access / on this server. 是由于没有设置访问目录 今天配置httpd-ssl.conf的时候 发现这个问题 由于默认 ...
- 跟我学算法-吴恩达老师的logsitic回归
logistics回归是一种二分类问题,采用的激活函数是sigmoid函数,使得输出值转换为(0,1)之间的概率 A = sigmoid(np.dot(w.T, X) + b ) 表示预测函数 dz ...
- S 导客户主数据 及更新销售团队、组织、品牌
一.导入客户主表(INSERT) EXCEL模板 [Public] ConnectString=host="siebel://10.10.0.46:2321/HC_CRM/SMObjMgr_ ...