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. 操作DOM -------JavaScrip

    本文摘要:http://www.liaoxuefeng.com/ 经常用到. 由于HTML文档被浏览器解析后就是一棵DOM树,要改变HTML的结构,就需要通过JavaScript来操作DOM. 始终记 ...

  2. (转)国内外优秀的Web前端工程师

    1. 国内外优秀的Web前端工程师 寻找Github.微博.知乎等技术社区上比较活跃.影响力大的圈内大神,供大家膜拜! 视野所限,未必全面,欢迎大家推荐.自荐. 排名不分先后,序号只为标记方便. 提供 ...

  3. 问题009:java当中的关键字有哪些?在Editplus文本编辑软件中是什么颜色的?java当中的标识符有什么要求?Java中注释分为几类?

    (1) public 公共的,表示访问的权限 (2) private 私有的,表示一种访问权限 (3) class 类关键字,表示定义一个类 java中的关键字都是大写的还是小写的?小写的,在Edit ...

  4. react的redux无状态组件

    Provider功能主要为以下两点: 在原应用组件上包裹一层,使原来整个应用成为Provider的子组件 接收Redux的store作为props,通过context对象传递给子孙组件上的connec ...

  5. pytthon + Selenium+chrome linux 部署

    1,centos7 安装 google-chrome (1) 添加chrome的repo源 vi /etc/yum.repos.d/google.repo [google] name=Google-x ...

  6. DeepFaceLab报错,OOM如何解决?

    DeepFaceLab出错,虽然错误提示好几个屏幕,但是无非两种情况,一种是驱动没装好,一种是显存配置不够.上一篇文章说了驱动的问题,这一篇就说说配置不够的问题. 这个问题的表现形式,往往是各种OOM ...

  7. 洛谷 P2205 [USACO13JAN]画栅栏

    这题其实没什么,但用到的算法都十分有用.做一个不恰当的比喻,这是一只必须用牛刀杀的鸡,但因为我这个蒟蒻杀不死牛,所以只能找只鸡来练练手. 题目描述 Farmer John 想出了一个给牛棚旁的长围墙涂 ...

  8. Maya材质

    mental ray--Indirect Lighting(物理学太阳天空)      Final Gathering最终聚集   改变质量为production的,FG就是关闭需要重新打开 平行光, ...

  9. v-model 的修饰符

    1..trim 自动过滤输入内容最开始 和 最后的 空格,中间的会保留一个空格,多的会被过滤掉 2..lazy 一般情况下,在input的 v-model是一直在同步 输入的内容与显示的内容,不过再添 ...

  10. 6 json和ajax传递api数据

    1 2 3 4 https://swapi.co/ <h1>Hello Reqwest!</h1> <script> var a = {} reqwest({ ur ...