2787 加密术

加密术

Time Limit: 1000MS  Memory Limit: 65536KB
Problem Description
加密技术是一种常用的安全保密手段,利用加密技术可以把重要的数据变成经过加密变成乱码传送,到达目的地后再利用解密手段还原。现在我们发明了一种新的加密技术,即通过在一个字符串的任意位置插入若干个随机生成的字符(‘a’~’z’或’A’~’Z’)对该字符串加密。
我们想要申请专利,但在这之前,需要做大量的检测。所以有必要编写一个程序判断加密后的字符串经过解密是否是加密前的字符串,即从加密后的字符串中删除若干个字符后剩下的字符串是否可以拼接成加密前的字符串。Can you help us ?
Input
输入包含多组,每组输入两个串(只包含大小写字母)S,T,中间用空格分开。S和T的长度不超过100000。
Output
对于每组输入,如果加密后的字符串解密后与加密前的字符串相同输出“Yes”,否则输出“No”。
Example Input
string  Strstring
HELLO  sdhfHqEiweqLbnLOqwerty
nomatter  nsomatstr
friend  FriEendly
Example Output
Yes
Yes
No
No
Hint
import java.util.*;
public class Main {

	public static void main(String[] args) {
	 Scanner cin = new Scanner(System.in);
	 while(cin.hasNext()){
		 String str = cin.next();
		 String str1 = cin.next();
		 
		 char s[] = str.toCharArray();
		 char s1[] = str1.toCharArray();
	     int t = 0;
		 for(int i = 0; i < str1.length() && t < str.length(); i++){
			 if(s[t] == s1[i])
				 t++;
		 }
		 
		 if(t == str.length()){
			 System.out.println("Yes");
			
		 }
		 else {
			 System.out.println("No");
		 }
	 
	 
	 }
	 
	}

}


import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int sum = 0;
		while(cin.hasNext()){
			String a = cin.next();
			char str1[] = a.toCharArray();
			String b = cin.next();
			char str2[] = b.toCharArray();
			int flag = 0;
			int top = 0;
			int i,j;
			for( i = 0; i < a.length(); i++){
				
				for( j = top ; j < b.length(); j++){
					if(str1[i] == str2[j]){
						break;
					}
					
					
				}
				top = j++;
				if(top == b.length()){
					flag = 1;break;
				}
			}
			if(flag == 1){
				System.out.println("No");
			}
			else{
				System.out.println("Yes");
			}
			
			
		}
			
	}
}

 
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值