(代码实现)北京大学-JudgeOnline-1936
来源:互联网 发布:会计视频课程 知乎 编辑:程序博客网 时间:2024/04/29 15:37
题目:
All in All
Time Limit:1000MS Memory Limit:30000K
Total Submit:5227 Accepted:1975
Description
You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way. Because of pending patent issues we will not discuss in detail how the strings are generated and inserted into the original message. To validate your method, however, it is necessary to write a program that checks if the message is really encoded in the final string.
Given two strings s and t, you have to decide whether s is a subsequence of t, i.e. if you can remove characters from t such that the concatenation of the remaining characters is s.
Input
The input contains several testcases. Each is specified by two strings s, t of alphanumeric ASCII characters separated by whitespace.The length of s and t will no more than 100000.
Output
For each test case output "Yes", if s is a subsequence of t,otherwise output "No".
Sample Input
Sample Output
代码:
//AC
#include <stdio.h>
#include <string.h>
char s[1000000],t[1000000];
int main()
{
long sl,tl,i,j;
while(scanf("%s %s",s,t)!=EOF)
{
i=0;
j=0;
sl=strlen(s);
tl=strlen(t);
while(1)
{
if(s[i]==t[j])
{
i++;
j++;
}
else
{
j++;
}
if(i==sl && j<tl+1)
{
printf("Yes/n");
break;
}
if(i<sl && j==tl)
{
printf("No/n");
break;
}
}
}
return 0;
}
思路:
这个题目,我觉的只能是一个一个字符的比较了,想不出有更好的办法了,不知道大家怎么想的;
YesNoYesNo
sequence subsequenceperson compressionVERDI vivaVittorioEmanueleReDiItaliacaseDoesMatter CaseDoesMatter
- (代码实现)北京大学-JudgeOnline-1936
- (代码实现)北京大学-JudgeOnline-1318
- (代码实现)北京大学-JudgeOnline-1004
- (代码实现)北京大学-JudgeOnline-1032
- (代码实现)北京大学-JudgeOnline-1504
- (代码实现)北京大学-JudgeOnline-2260
- JudgeOnline
- ACM题目分类——北京大学(POJ)篇
- 2011年北京大学计算机研究生机试真题(题解)
- 北京大学互联网信息工程研发中心(深圳)
- 北京大学 C程序设计进阶 习题答案(一)
- 北京大学ACM---poj3750---小孩报数问题(循环链表求解法)
- 编程作业 简单的学生信息处理程序实现[北京大学C++课程]
- 中央巡视组进驻北京大学,争当第一鸣冤人的梦想终于实现了!
- http://acm.pku.edu.cn/JudgeOnline/problem?id=1284 (原根)
- n-1位数(http://acm.nyist.net/JudgeOnline/problem.php?pid=96)
- http://begin.lydsy.com/JudgeOnline/problem.php?id=2770(PKU2503 Babelfish)
- http://begin.lydsy.com/JudgeOnline/problem.php?id=2774(poi病毒)
- 第一个cpp程序
- oracle数据库还原,如何将dmp文件还原到oralce库
- gmail客户端设置
- 中国古代著名少数民族的下落
- 战国都城形态的东西差别
- (代码实现)北京大学-JudgeOnline-1936
- (代码实现)北京大学-JudgeOnline-2260
- 关于cookie的httponly属性
- 成长中的理想主义
- 国际风险投资的运作步骤
- 轻松去除桌面图标阴影
- 风险投资案例典型分析
- JSP中连接数据库的技术
- 游戏中基于物理的反射——简介(系列一)