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.

Examples

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

题意:输入两个字符串,如果第一个字符串的位数为8位以下,则两个字符串必须完全相同才输出“yes”,否则输出“no”。当第一个字符串的长度大于8位时,则第二个字符串可以比第一个字符串少一个字符,或与第一个字符串一个字符不相同,输出即为“yes”,其余情况均输出“no”。
题解:可分为四种情形,我们可以对其逐一进行判断,第一种:是第一个字符串比第二个字符串多两个字符,或者第二个字符串比第一个字符串多,即输出“no”;第二种,第一个字符串长度小于8,两个字符串必须完全相同才“yes”;第三种,两个字符串长度相等,定义一个变量flag,对其不相同的次数进行计数,超过2即为“no”;第四种就是第一个字符串比第二个字符串多1个字符的情形。注意:各种情形的判断顺序不可随意调动。具体情况详见代码所示:
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#define ll long long
using namespace std;
int main(){
string s1,s2;
cin>>s1>>s2;
int flag=;
int a=s1.length(),b=s2.length();
if(a<b||a-b>) cout<<"no"<<endl;
else if(a<)
{
if(s1==s2) cout<<"yes"<<endl;
else cout<<"no"<<endl;
}
else if(a==b)
{
for(int i=;i<a;i++)
{
if(s1[i]!=s2[i]) flag++;
}
if(flag>) cout<<"no"<<endl;
else cout<<"yes"<<endl;
}
else
{
int num1=,num2=;
while(num1<a&&num2<b)
{
if(s1[num1]!=s2[num2])
{ //当第一个字符串比第二个多一个字符时,不一样时,只增加第一个字符串的下标
num1++;
flag++;
}
else
{
num1++;
num2++;
}
if(flag==) break;
}
if(flag==) cout<<"no"<<endl;
else cout<<"yes"<<endl;
}
return ;
}

Gym - 100989E的更多相关文章

  1. Gym 100989E 字符串

    Description standard input/output Islam is usually in a hurry. He often types his passwords incorrec ...

  2. UESTC 2016 Summer Training #1 Div.2

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

  3. ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力

     Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS     Memory Limit:65536KB     64bit IO Fo ...

  4. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

  5. ACM: Gym 101047E Escape from Ayutthaya - BFS

    Gym 101047E Escape from Ayutthaya Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I6 ...

  6. ACM: Gym 101047B Renzo and the palindromic decoration - 手速题

     Gym 101047B  Renzo and the palindromic decoration Time Limit:2000MS     Memory Limit:65536KB     64 ...

  7. Gym 101102J---Divisible Numbers(反推技巧题)

    题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...

  8. Gym 100917J---Judgement(01背包+bitset)

    题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...

  9. Gym 100917J---dir -C(RMQ--ST)

    题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...

随机推荐

  1. Lumen与laravel的区别

    Lumen与laravel的区别   困惑 一直都无法很友好的理解Lumen与Laravel之间的区别,只知道他们是非常相似的两个php框架,使用方法什么的都差不多. 为什么要解惑 最近接手了公司的一 ...

  2. tomcat server.xml各个端口的作用

    <Server port="8005" shutdown="SHUTDOWN"> <!-- port:指定一个端口,这个端口负责监听关闭Tom ...

  3. Oracle的数据类型详述

    数据类型 (1)字符型 CHAR: 定长最多(2000字节)特定情况下用 VARCHAR2:可变长度的字符串最多(4000字节) LONG:大文本类型最多(2个G) (2)数值型 NUMBER:可以是 ...

  4. ArrayList性能短板深入分析

    ArrayList的数据结构主体是Object[]数组,数组对象在内存的位置是成块成块的. 1.对数组进行非尾部修改,会引发System.arrayCopy()行为.这就需要对后半部要移动的对象进行内 ...

  5. 原生JS实现增加删除class

    <!DOCTYPE html> <html> <head> <style type="text/css"> .night-mode{ ...

  6. 【纪录】Proxychain4 使用部署以及利用 ss 加速下载操作

    我觉得这个方案用来解决 linux 机器上面 apt-get 和 yum 国外源拉去取过慢的问题还是还不错的. 参看下面两个教程. Reference: https://brickyang.githu ...

  7. WEB测试重点--(转载)

    1.功能测试: 所实现的功能是否和需求一致: js错误 页面链接错误-空链接.死链接.错误链接 按钮无效 未实现功能 报错提示信息不准确或不友好 数据库访问错误 sql注入 文档上传下载问题 -未实现 ...

  8. How to remove unwant Internet Explorer Context Menu

    HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt

  9. caffe网络中屏蔽某一层的输出Silence层

    屏蔽label输出 layer { name: "silence0" type: "Silence" bottom: "label" pha ...

  10. Tuple Class

    Inheritance Hierarchy   System.Object  System.Tuple Methods   Name Description Create<T1>(T1) ...