UVA 10340 (13.08.25)
Problem E
All in All
Input: standard input
Output: standard output
Time Limit: 2 seconds
Memory Limit: 32 MB
You have devised a new encryption technique whichencodes a message by inserting between its characters randomly generatedstrings in a clever way. Because of pending patent issues we will not discussin detail how the strings are generated and inserted into the original message.To validate your method, however, it is necessary to write a program thatchecks if the message is really encoded in the final string.
Given two strings s and t, you haveto decide whether s is a subsequence of t, i.e. if you can removecharacters from t such that the concatenation of the remainingcharacters is s.
Input Specification
The input contains several testcases. Each isspecified by two strings s, t of alphanumeric ASCII characters separatedby whitespace. Input is terminated by EOF.
Output Specification
For each test case output, if s is asubsequence of t.
Sample Input
sequence subsequence
person compression
VERDI vivaVittorioEmanueleReDiItalia
caseDoesMatter CaseDoesMatter
SampleOutput
Yes
No
Yes
No
题意:
在字符串2中找字符串1
然后, 其实我不想说思路了
直接贴AC代码:
#include<stdio.h>
#include<string.h> char str1[100005];
char str2[100005]; int main() {
while(scanf("%s %s", str1, str2) != EOF) {
int len1, len2;
len1 = strlen(str1);
len2 = strlen(str2);
int i;
int mark = 0;
int pos = 0;
for(i = 0; i < len2; i++) {
if(str1[pos] == str2[i]) {
pos++;
if(pos >= len1)
mark = 1;
}
}
if(mark)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
UVA 10340 (13.08.25)的更多相关文章
- UVA 10041 (13.08.25)
Problem C: Vito's family Background The world-known gangster Vito Deadstone is moving to New York. ...
- UVA 639 (13.08.25)
Don't Get Rooked In chess, the rook is a piece that can move any number of squaresvertically or ho ...
- UVA 10194 (13.08.05)
:W Problem A: Football (aka Soccer) The Problem Football the most popular sport in the world (ameri ...
- UVA 10499 (13.08.06)
Problem H The Land of Justice Input: standard input Output: standard output Time Limit: 4 seconds In ...
- UVA 253 (13.08.06)
Cube painting We have a machine for painting cubes. It is supplied withthree different colors: blu ...
- UVA 156 (13.08.04)
Ananagrams Most crossword puzzle fans are used to anagrams--groupsof words with the same letters i ...
- UVA 573 (13.08.06)
The Snail A snail is at the bottom of a 6-foot well and wants to climb to the top.The snail can cl ...
- UVA 10025 (13.08.06)
The ? 1 ? 2 ? ... ? n = k problem Theproblem Given the following formula, one can set operators '+ ...
- UVA 465 (13.08.02)
Overflow Write a program that reads an expression consisting of twonon-negative integer and an ope ...
随机推荐
- Winter(bfs&&dfs)
1084 - Winter PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Winter is ...
- Objective-c 协议(protocol)
协议的作用类似地C++中对抽象基类的多重继承.类似于Java中的接口(interface)的概念. 协议是多个类共享方法的列表,协议中列出的方法在本类中并没有相应实现,而是别的类来实现这些方法. ...
- Ext JS学习第十二天 Ext基础之操作dom ; get与fly 方法
此文用来记录学习笔记 •嗯!首先,什么是DOM(Document Object Model) –W3C对DOM的定义:文档对象模型是一个平台,一个中立于语言的应用程序编程接口(API),允许程序访问并 ...
- Decorator Pattern(装饰模式)
装饰模式:动态的给一个对象添加一些额外的职责.当然我们也可以通过继承来实现类似的功能,但是随着子类的增多,各种子类的组合会造成子类的急剧膨胀. Requirement: 假设客户有一个要求,需要打一个 ...
- Java中 hashCode()方法详解
先来看下Object源码里hashcode方法: /** * Returns a hash code value for the object. This method is * s ...
- PHP 判断数据类型
isset()://变量是否已经声明 empty()://变量是否为空 defined()://常量是否已经定义 define() array_key_exists(mixed key, array ...
- [mysql]子查询与连接
1,子查询(Subquery)是指出现在其他 SQL 语句内的select子句 例如: select * from t1 where col1 = (select col2 from t2); 其中 ...
- Flask中全局变量的实现
我们都知道在Flask中g,request,session和request是作为全局对象来提供信息的,既然是全局的又如何保持线程安全呢,接下来我们就看看flask是如何做到这点的.在源码中的ctx.p ...
- 使用 Async 和 Await 的异步编程 #Reprinted#
异步方法容易编写 string urlContents = await client.GetStringAsync(); 以下特征总结了使上面一个异步方法. 方法签名包含一个 Async 或async ...
- gdb图形化调试工具总结
gdb除了命令行方式等的调试之外,还有图形化的调试工具,下面列举一些供参考 1:insight 2: ddd 3: kgdb 4: xxgdb 其它的工具欢迎补充