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

纯粹的联系String的substr

什么时候substr拦截比写短话

string te;
int n;
te="Hellow";
cout << te.substr(3,5);

我试了下 打印出来的是low....

写的时候没去限制边界还是AC了

//#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std; #define ls(rt) rt*2
#define rs(rt) rt*2+1
#define ll long long
#define ull unsigned long long
#define rep(i,s,e) for(int i=s;i<e;i++)
#define repe(i,s,e) for(int i=s;i<=e;i++)
#define CL(a,b) memset(a,b,sizeof(a))
#define IN(s) freopen(s,"r",stdin)
#define OUT(s) freopen(s,"w",stdout)
const ll ll_INF = ((ull)(-1))>>1;
const double EPS = 1e-8;
const double pi = acos(-1.0);
const int INF = 100000000; int main()
{
string s;
while(cin>> s )
{
int len=s.size();
for(int i=0;i<len;i++)
{
string s4=s.substr(i,4);
string s5=s.substr(i,5);
string s6=s.substr(i,6);
if(s4 == "iPod" || s4 == "iPad" || s5 == "Apple" || s6=="iPhone")
puts("MAI MAI MAI!");
if(s4 == "Sony")
puts("SONY DAFA IS GOOD!");
}
}
return 0;
}

版权声明:本文博主原创文章,博客,未经同意不得转载。

hdu 5007 水 弦的更多相关文章

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

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

  2. HDU-1042-N!(Java大法好 &amp;&amp; HDU大数水题)

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Subm ...

  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 KMP (ICPC西安赛区网络预选赛 1001)

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

  5. hdu 4464 水

    http://acm.hdu.edu.cn/showproblem.php?pid=4464 现场赛总会有水题,这就是最水的一道,预计也就是能当高校的上机题,保研用,呵呵~~~ #include &l ...

  6. hdu 5007

    http://acm.hdu.edu.cn/showproblem.php?pid=5007 字符串处理 暴力 #include <cstdio> #include <cstdlib ...

  7. HDU 5391 水题。

    E - 5 Time Limit:1500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

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

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

  9. hdu 1544 水题

    水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...

随机推荐

  1. My blog

    欢迎啦……嘿嘿 http://blog.csdn.net/zuguodexiaoguoabc http://blog.sina.com.cn/u/3914181130

  2. BZOJ 1407: [Noi2002]Savage( 数论 )

    枚举答案, 然后O(N^2)枚举野人去判他们是否会在有生之年存在同山洞. 具体做法就是: 设第x年相遇, 则 Ci+x*Pi=Cj+x*Pj (mod M), 然后解同余方程. 复杂度应该是O(ans ...

  3. leetcode Climbing Stairs python

    class Solution(object): def climbStairs(self, n): """ :type n: int :rtype: int " ...

  4. 计算BMI指数的小程序

    小明身高1.75,体重80.5kg.请根据BMI公式(体重除以身高的平方)帮小明计算他的BMI指数,并根据BMI指数: 低于18.5:过轻 18.5-25:正常 25-28:过重 28-32:肥胖 高 ...

  5. 四轴飞行器1.2.2 RT-Thread 串口

    四轴飞行器1.2.2 RT-Thread 串口        本来是打算说根据RT-Thread的设备管理提供的驱动接口些串口驱动的,但是仔细一看,我去,串口驱动写好了,只需要调用就可以了.下面我们说 ...

  6. 类比的方法学习Performance_schema

    引用自:http://www.javacoder.cn/?p=332 MySQL在5.6版本中包含了一个强大的特性——performance-schema,合理的使用这个数据库中的表,能为我们解决一些 ...

  7. Mysql 权限修改何时生效

    首先权限是记录在表中的,所以如果我们要修改权限只要修改表中的数据就可以了! 方法 1 grant ,revoke,set password,rename user .......等等 2 insert ...

  8. openStack 王者归来之 trivial matters

    <一,openStack img 制作> tips:制作大部分cloud platforms img准备工作. <1,> http://www.pubyun.com/blog/ ...

  9. 23种设计模式的C++实现

    之前看Head First设计模式的时候照着书上的代码实现了一个C++版本(书上是Java版本的),代码上传在https://github.com/clpsz/Book-HFDP-Code. 当时因为 ...

  10. STL-multimap

    转自:http://www.cnblogs.com/xiaoka/archive/2011/08/09/2132342.html multimap提供了可以一种可以有重复键值的STL map类型.其插 ...