加密术

来源:互联网 发布:js数组字符串方法 编辑:程序博客网 时间:2024/05/01 12:45

加密术

Time Limit: 1000MS Memory Limit: 65536KB
SubmitStatistic

Problem Description

加密技术是一种常用的安全保密手段,利用加密技术可以把重要的数据变成经过加密变成乱码传送,到达目的地后再利用解密手段还原。现在我们发明了一种新的加密技术,即通过在一个字符串的任意位置插入若干个随机生成的字符(‘a’~’z’或’A’~’Z’)对该字符串加密。
我们想要申请专利,但在这之前,需要做大量的检测。所以有必要编写一个程序判断加密后的字符串经过解密是否是加密前的字符串,即从加密后的字符串中删除若干个字符后剩下的字符串是否可以拼接成加密前的字符串。Can you help us ?

Input

输入包含多组,每组输入两个串(只包含大小写字母)S,T,中间用空格分开。S和T的长度不超过100000。

Output

对于每组输入,如果加密后的字符串解密后与加密前的字符串相同输出“Yes”,否则输出“No”。

Example Input

string  StrstringHELLO  sdhfHqEiweqLbnLOqwertynomatter  nsomatstrfriend  FriEendly

Example Output

YesYesNoNo

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int i, j;while(scanner.hasNext()) {char[] c1 = scanner.next().toCharArray();char[] c2 = scanner.next().toCharArray();//System.out.println(c1.length);j = 0;for(i = 0; i < c2.length && j < c1.length; i ++) {if(c2[i] == c1[j]) {j ++;}}if(j >= c1.length) {System.out.println("Yes");} else{System.out.println("No");}}}}//判断连续字符/*CharSequence string = scanner.next();String string2 = scanner.next();boolean bool = string2.contains(string);if(bool == true) {System.out.println("Yes");} else {System.out.println("No");}*///indexOf也是判断连续字符,看其首次出现的位置






0 0