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
  1. AgentMahone
    IslamIsMahone
Output
  1. no
Input
  1. ofmahone
    ofmahome
Output
  1. yes
Input
  1. algorithms
    algorthms
Output
  1. yes
Input
  1. Mahone
    mahonE
Output
  1. no
  2.  
  3. 题意:输入两个字符串,如果第一个字符串的位数为8位以下,则两个字符串必须完全相同才输出“yes”,否则输出“no”。当第一个字符串的长度大于8位时,则第二个字符串可以比第一个字符串少一个字符,或与第一个字符串一个字符不相同,输出即为“yes”,其余情况均输出“no”。
    题解:可分为四种情形,我们可以对其逐一进行判断,第一种:是第一个字符串比第二个字符串多两个字符,或者第二个字符串比第一个字符串多,即输出“no”;第二种,第一个字符串长度小于8,两个字符串必须完全相同才“yes”;第三种,两个字符串长度相等,定义一个变量flag,对其不相同的次数进行计数,超过2即为“no”;第四种就是第一个字符串比第二个字符串多1个字符的情形。注意:各种情形的判断顺序不可随意调动。具体情况详见代码所示:
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cstring>
  4. #include<string>
  5. #include<algorithm>
  6. #include<stack>
  7. #include<queue>
  8. #define ll long long
  9. using namespace std;
  10. int main(){
  11. string s1,s2;
  12. cin>>s1>>s2;
  13. int flag=;
  14. int a=s1.length(),b=s2.length();
  15. if(a<b||a-b>) cout<<"no"<<endl;
  16. else if(a<)
  17. {
  18. if(s1==s2) cout<<"yes"<<endl;
  19. else cout<<"no"<<endl;
  20. }
  21. else if(a==b)
  22. {
  23. for(int i=;i<a;i++)
  24. {
  25. if(s1[i]!=s2[i]) flag++;
  26. }
  27. if(flag>) cout<<"no"<<endl;
  28. else cout<<"yes"<<endl;
  29. }
  30. else
  31. {
  32. int num1=,num2=;
  33. while(num1<a&&num2<b)
  34. {
  35. if(s1[num1]!=s2[num2])
  36. { //当第一个字符串比第二个多一个字符时,不一样时,只增加第一个字符串的下标
  37. num1++;
  38. flag++;
  39. }
  40. else
  41. {
  42. num1++;
  43. num2++;
  44. }
  45. if(flag==) break;
  46. }
  47. if(flag==) cout<<"no"<<endl;
  48. else cout<<"yes"<<endl;
  49. }
  50. return ;
  51. }

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. 关于spring的源码的理解

    从最基础的Hello World开始. spring的Hello World就三行代码: public void test() { ApplicationContext context = new C ...

  2. oss上传和下载的笔记

    <<<<<<<<<对oss操作,上传文件>>>>>>>>>>>>>& ...

  3. leetcode:Roman to Integer and Integer to Roman

    2015-06-03 罗马数字以前接触过I到VIII比较多,直到遇见这个题目才知道更详细.阿拉伯数字和罗马数字之间的转换最重的是了解罗马数字的规则. 罗马数字规则:(总结) 1, 罗马数字共有7个,即 ...

  4. 剑指offer(5)

    题目: 用两个栈来实现一个队列,完成队列的Push和Pop操作. 队列中的元素为int类型. 解法: 一个栈专门用来存数,当需要输出数时,把所有数倒到第二个栈,当然,若此时第二个栈中已经有数了(之前倒 ...

  5. ubuntu18.04 安装 php7.2

    sudo apt-get install software-properties-common python-software-properties sudo add-apt-repository p ...

  6. 隐藏Nginx或Apache以及PHP的版本号的方法

    当黑客入侵一台服务器时,首先会”踩点”, 这里的”踩点”,指的是了解服务器中运行的一些服务的详细情况,比如说:版本号,当黑客知道相应服务的版本号后,就可以寻找该服务相应版本的一些漏洞来入侵,攻击,所以 ...

  7. Redis事物

    redis事物定义: >Redis事务是一个单独的隔离操作:事务中的所有命令都会序列化.按顺序地执行.事务在执行的过程中,不会被其他客户端发送来的命令请求所打断. >Redis事务的主要作 ...

  8. /dev被异常删除的问题

    今天遇到一个问题,在执行某些操作后,发现经常报“read_urandom: /dev/urandom: open failed: No such file or directory”这个错误.后来查看 ...

  9. 当应用程序不是以UserInteractive 模式运行时显示模式对话框或窗体

    最近在做一个WCF程序的时候,WCF程序老是弹出一个错误“当应用程序不是以UserInteractive 模式运行时显示模式对话框或窗体是无效操作.请指定ServiceNotification或Def ...

  10. shell中的>,2>&1,&>file 解析记录

    0  表示标准输入1  表示标准输出2  表示标准错误输出>  默认为标准输出重定向,与 1> 相同2>&1  意思是把 标准错误输出 重定向到 标准输出.&> ...