Description

standard input/output

Islam is usually in a hurry. He often types his passwords incorrectly. He hates retyping his password several times whenever he tries to login, especially that his passwords are usually very long. He believes that websites should be tolerant with very long passwords. In other words, he believes that if a password is very long, and there is only one mistake in the password, the website should allow the user to login.

Your task is to check if an entered password should be accepted according to Islam, or not. The entered password will be accepted if it matches the user’s password, or if the user’s password length is at least 8 characters and the user made a mistake with only one character (either replaced it with a wrong character or dropped it).

Given the user’s password, and the entered password, determine if the entered password should be accepted according to Islam.

Input

The first line of input contains the user’s password.

The second line of input contains the entered password.

Both strings contain only lowercase and uppercase English letters.

The length of each string is at least 1 and at most 100.

Output

Print yes if the entered password should be accepted according to Islam, otherwise print no.

Sample Input

 

Input
AgentMahone
IslamIsMahone
Output
no
Input
ofmahone
ofmahome
Output
yes
Input
algorithms
algorthms
Output
yes
Input
Mahone
mahonE
Output
no

题意:

题解:给两个串a,b; a的长度len1 b的长度len2   a长度小于8的直接判断,长度大于等于8的 根据题意 
两个串的长度只存在 len1==len2或者 len1-len2=1两种情况才可能yes,分别特判一下就可以了。
   len1==len2情况下 只能是两个串相同或者某一个字母被替换,遍历一遍验证
   len1-len2==1 情况下 只能是丢失一个字母  遍历一遍 当遇到字母不同时,b串向后移动一位继续遍历
                       当只出现一次对应字母不同时,才能说明只丢失了一个字母
 #include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char a[];
char b[];
int main()
{
scanf("%s",a);
scanf("%s",b);
int len1=strlen(a);
int len2=strlen(b);
if(len1<)
{
if(strcmp(a,b)==)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
else
{
if(len2>len1)
{
cout<<"no"<<endl;
return ;
}
if(strcmp(a,b)==)
{
cout<<"yes"<<endl;
return ;
}
int flag=;
if(len1==len2)
{
for(int i=;i<len1;i++)
{
if(a[i]!=b[i])
{
flag++;
}
}
if(flag==)
{
cout<<"yes"<<endl;
return ;
}
else
{
cout<<"no"<<endl;
return ;
}
}
if(len1-len2==)
{
for(int i=;i<len1;i++)
{
if(a[i]!=b[i])
{
for(int j=len2-;j>=i;j--)
{
b[j+]=b[j];
}
b[i]=' ';
flag++;
}
}
if(flag==)
{
cout<<"yes"<<endl;
return ;
}
else
{
cout<<"no"<<endl;
return ;
}
}
cout<<"no"<<endl;
}
return ;
}

Gym 100989E 字符串的更多相关文章

  1. D - Counting Test Gym - 101532D 字符串

    Yousef has a string s that is used to build a magical string w by repeating the string s infinitely ...

  2. Gym - 100989E

    Islam is usually in a hurry. He often types his passwords incorrectly. He hates retyping his passwor ...

  3. UESTC 2016 Summer Training #1 Div.2

    最近意志力好飘摇..不知道坚不坚持得下去.. 这么弱还瞎纠结...可以滚了.. 水题都不会做.. LCS (A) 水 LCS (B) 没有看题 Gym 100989C 水 1D Cafeteria ( ...

  4. ACM: Gym 100935B Weird Cryptography - 简单的字符串处理

    Weird Cryptography Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u ...

  5. Gym 100952C&&2015 HIAST Collegiate Programming Contest C. Palindrome Again !!【字符串,模拟】

    C. Palindrome Again !! time limit per test:1 second memory limit per test:64 megabytes input:standar ...

  6. Gym 100952A&&2015 HIAST Collegiate Programming Contest A. Who is the winner?【字符串,暴力】

    A. Who is the winner? time limit per test:1 second memory limit per test:64 megabytes input:standard ...

  7. Codeforces Gym 100338B Spam Filter 字符串哈希+贝叶斯公式

    原题链接:http://codeforces.com/gym/100338/attachments/download/2136/20062007-winter-petrozavodsk-camp-an ...

  8. 强化学习实战 | 自定义gym环境之显示字符串

    如果想用强化学习去实现扫雷.2048这种带有数字提示信息的游戏,自然是希望自定义 gym 环境时能把字符显示出来.上网查了很久,没有找到gym自带的图形工具Viewer可以显示字符串的信息,反而是通过 ...

  9. codeforces gym 100286 I iSharp (字符串模拟)

    题目链接 给定一个字符串.输入是int& a*[]&, b, c*; 输出是 int&&[]* a;int& b;int&* c; 输入格式里逗号后面一 ...

随机推荐

  1. 题解 P2626 【斐波那契数列(升级版)】

    这道题,大家一定要注意: 要对2^31取模 ! ( 本蒟蒻开始没注意到这一点,WA了 ) (不过大家在试样例的时候,试试47,出不了结果,就说明你没模2^31) 总体来说,这道题考查的知识点就两个: ...

  2. Bootstrap 历练实例 - 按钮(Button)插件复选框

    复选框(Checkbox) 您可以创建复选框按钮 组,并通过向 btn-group 添加 data 属性 data-toggle="buttons" 来添加复选框按钮组的切换. & ...

  3. vue:vue router学习小结

    序:本篇内容主要侧重对前端路由的理解,以vue的官方路由作为载体,进行一个简单介绍. 一.路由历史: 最早开始的时候,项目开发使用的是SSR,即服务端渲染.这个时候刷新页面,服务器返回的是全部的htm ...

  4. react的ant design的UI组件库

    PC官网:https://ant.design/ 移动端网址:https://mobile.ant.design/docs/react/introduce-cn antd-mobile :是 Ant ...

  5. 你所不知道的js的小知识点(1)

    1.js调试工具 debugger <div class="container"> <h3>debugger语句会产生一个断点,用于调试程序,并没有实际功能 ...

  6. Qt之QThread随记

    这是一篇随记,排版什么的就没有那么好了:) 首先要知道,一个线程在资源分配完之后是以某段代码为起点开始执行的,例如STL内的std::thread,POSIX下的pthread等,都是以函数加其参数之 ...

  7. CentOS7 ngnix 的安装和配置

    刚开始我也在纠结到底是该用Apache呢还是Nginx?然后网上各种查看了它俩的对比,总结了它俩最大区别在于apache是同步多进程模型,在处理动态有优势:nginx是异步的,并发性能比较好,cpu内 ...

  8. LeetCode948-令牌放置

    问题:令牌放置 你的初始能量为 P,初始分数为 0,只有一包令牌. 令牌的值为 token[i],每个令牌最多只能使用一次,可能的两种使用方法如下: 如果你至少有 token[i] 点能量,可以将令牌 ...

  9. jsp--提交表单→插入数据库→成功后返回提示信息

    <%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="u ...

  10. python面向对象之反射和内置方法

    一.静态方法(staticmethod)和类方法(classmethod) 类方法:有个默认参数cls,并且可以直接用类名去调用,可以与类属性交互(也就是可以使用类属性) 静态方法:让类里的方法直接被 ...