A. Cutting Banner
来源:互联网 发布:数据蒙特卡洛 编辑:程序博客网 时间:2024/05/16 15:49
A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami beach. Unfortunately, the company that made the banner mixed up two orders and delivered somebody else's banner that contains someone else's word. The word on the banner consists only of upper-case English letters.
There is very little time to correct the mistake. All that we can manage to do is to cut out some substring from the banner, i.e. several consecutive letters. After that all the resulting parts of the banner will be glued into a single piece (if the beginning or the end of the original banner was cut out, only one part remains); it is not allowed change the relative order of parts of the banner (i.e. after a substring is cut, several first and last letters are left, it is allowed only to glue the last letters to the right of the first letters). Thus, for example, for example, you can cut a substring out from string 'TEMPLATE' and get string 'TEMPLE' (if you cut out string AT), 'PLATE' (if you cut out TEM), 'T' (if you cut out EMPLATE), etc.
Help the organizers of the round determine whether it is possible to cut out of the banner some substring in such a way that the remaining parts formed word CODEFORCES.
The single line of the input contains the word written on the banner. The word only consists of upper-case English letters. The word is non-empty and its length doesn't exceed 100 characters. It is guaranteed that the word isn't word CODEFORCES.
Print 'YES', if there exists a way to cut out the substring, and 'NO' otherwise (without the quotes).
CODEWAITFORITFORCES
YES
BOTTOMCODER
NO
DECODEFORCES
YES
DOGEFORCES
NO
解题说明:此题是判断一个字符串中是否包含给定的子串,遍历即可。
#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>#include<cmath>using namespace std;int main(){ int i, j; int length; char s[1005]; char codefoeces[] = "CODEFORCES"; scanf("%s",s); length = strlen(s); i = j = 0; while ( i < 10 && s[i] == codefoeces[i] ) {i++;} while ( j < 10 && s[length-1-j] == codefoeces[9-j] ) {j++;}if ( i+j >= 10 ) {printf("YES\n");}else {printf("NO\n");}return 0;}
- codeforces A. Cutting Banner
- 538A - Cutting Banner
- A. Cutting Banner
- codeforces 538 A.Cutting Banner
- codeforces 538 A Cutting Banner
- codeforces #300 A. Cutting Banner
- #300 (div.1 2) A. Cutting Banner
- 第一次打CODEFORCES-----A. Cutting Banner
- CF 538A(Cutting Banner-暴力找切割点)
- contest: Codeforces Round #300, problem: (A) Cutting Banner
- contest: Codeforces Round #300, problem: (A) Cutting Banner
- Code Forces 538 A. Cutting Banner(水~)
- A538: Cutting Banner
- [CF538A]Cutting Banner
- Codeforces Round #300-Cutting Banner(substr函数的应用)
- codeforces----193A Cutting Figure
- CodeForces 193A Cutting Figure
- UVA 10867 Cutting a Polygon
- mysql函数(一)
- Sicily 1210. 二叉树
- 【转】mysql分页原理和高效率的mysql分页查询语句
- 近面裁剪
- 二叉树的递归遍历与非递归遍历
- A. Cutting Banner
- Windows7下如何删除鼠标右键的百度云同步和上传菜单
- AES加密 实现
- 进程3
- 【Hadoop系列】第一章:Hadoop生态系统概述以及版本演化
- JavaBean的相关知识
- Oracle 10g RAC Cluster interconnects
- 错误:浏览器访问jsp页面,却变成了下载该页面
- 使用InternetGetConnectedState这个API判断网络是否连通