http://acm.hdu.edu.cn/showproblem.php?pid=5007

字符串处理

暴力

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define clr0(x) memset(x,0,sizeof(x)) typedef long long LL;
char s[40000];
int n;
int main(){
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
//cout<<(8*1024*4);
char a[10] = "Apple",b[10] = "iPhone",c[10] = "iPod",d[10] = "iPad",e[10] = "Sony";
while(scanf("%s",s)!=EOF){
n = strlen(s);
for(int i = 0;i < n;){
if(s[i] == 'A' && i + 4 < n){
if(s[i+1] == 'p' && s[i+2] == 'p' && s[i+3] == 'l' && s[i + 4] == 'e'){
puts("MAI MAI MAI!");
i = i + 5;
}
else
++i;
}
else if(s[i] == 'S' && i + 3 < n){
if(s[i+1] == 'o' && s[i+2] == 'n' && s[i+3] == 'y'){
puts("SONY DAFA IS GOOD!");
i = i + 5;
}
else
++i;
}
else if(s[i] == 'i' && i+1 < n && s[i+1] == 'P'){
bool flag = false;
if(i+3 < n && s[i+3] == 'd')
if(s[i+2] == 'o' || s[i+2] == 'a'){
puts("MAI MAI MAI!");
i = i + 3;
flag = true;
}
if(i + 5 < n && s[i+2] == 'h' && s[i+3] == 'o' && s[i + 4] == 'n' && s[i+5] == 'e'){
puts("MAI MAI MAI!");
i = i + 4;
flag = true;
}
if(!flag)
++i;
}
else ++i;
}
}
return 0;
}

hdu 5007的更多相关文章

  1. HDU 5007 Post Robot KMP (ICPC西安赛区网络预选赛 1001)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5007 解题报告:输入一篇文章,从头开始,当遇到 “Apple”, “iPhone”, “iPod”, ...

  2. hdu 5007 水 弦

    http://acm.hdu.edu.cn/showproblem.php?pid=5007 纯粹的联系String的substr 什么时候substr拦截比写短话 string te; int n; ...

  3. hdu - 5007 Post Robot (水题)

    http://acm.hdu.edu.cn/showproblem.php?pid=5007 #include<iostream> #include<stdio.h> #inc ...

  4. 【HDU 5007】Post Robot

    Description DT is a big fan of digital products. He writes posts about technological products almost ...

  5. 2014 ACM/ICPC Asia Regional Xi'an Online(HDU 5007 ~ HDU 5017)

    题目链接 A题:(字符串查找,水题) 题意 :输入字符串,如果字符串中包含“ Apple”, “iPhone”, “iPod”, “iPad” 就输出 “MAI MAI MAI!”,如果出现 “Son ...

  6. HDU 5007 Post Robot

    Post Robot Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  7. hdu 5007 水题 (2014西安网赛A题)

    题意:出现Apple.iPod.iPhone.iPad时输出MAI MAI MAI!,出现Sony,输出SONY DAFA IS GOOD! Sample InputApple bananaiPad ...

  8. Spring-1-A Post Robot(HDU 5007)解题报告及测试数据

    Post Robot Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K Problem Description ...

  9. HDU 5007 字符串匹配

    http://acm.hust.edu.cn/vjudge/contest/122814#problem/A 匹配到字符串就输出,水题,主要是substr的运用 #include <iostre ...

随机推荐

  1. Spring,Hibernate 集成解决多hbm.xml文件繁多的方案

    开发一个大一点的项目有很多的hbm.xml文件,有时候上百个也不稀奇,如果用 <property name="mappingLocations"> <list&g ...

  2. scala-学习 2

    列表操作 List() 或者是 Nil 空list scala> val a = List() a:List[Nothing] = List() print(a.length) a.length ...

  3. shell脚本面试题

    Q:1 Shell脚本是什么.它是必需的吗? 答:一个Shell脚本是一个文本文件,包含一个或多个命令.作为系统管理员,我们经常需要使用多个命令来完成一项任务,我们可以添加这些所有命令在一个文本文件( ...

  4. 配置MySQL 5.6的主从复制

    工具/原料   Windows 7 64位 MySQL 5.6 配置新数据库的主从复制   1 先在主数据库中创建新数据库rep_test. 然后编辑主数据库的my.ini文件 在[mysqld]节点 ...

  5. 第八章 高级搜索树 (a2)伸展树:双层伸展

  6. 用SQL2000还原bak文件

    1.右击SQL Server 2000实例下的“数据库”文件夹.就是master等数据库上一级的那个图标.选择“所有任务”,“还原数据库” 2.在“还原为数据库”中填上你希望恢 复的数据库名字.这个名 ...

  7. [leetcode]143. Reorder List重排链表

    Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You may not mod ...

  8. [leetcode]239. Sliding Window Maximum滑动窗口最大值

    Given an array nums, there is a sliding window of size k which is moving from the very left of the a ...

  9. jquery-jsonp插件解决跨域问题

    用jquery-jsonp插件解决ajax跨域问题,既可以实现ajax同样的请求效果,而且server服务端的相关代码也不用做任何改变. 代码如下: var url="http://loca ...

  10. 图像获取与采集及图像格式与Region介绍——第2讲

    一.图像获取与采集 1.本地图片读取 ① 单张读取 直接传入图片路径即可,可以用绝对路径,也可以用相对路径: read_image (Image, 'C:/Users/Administrator/De ...