Content

\(\texttt{Freda}\) 和 \(\texttt{Rainbow}\) 在网上聊了 \(n\) 句话。我们根据他们聊天的语句的特点来判断每一句是谁说的。\(\texttt{Freda}\) 说的话结尾带有 \(\texttt{lala.}\),而 \(\texttt{Rainbow}\) 说的话开头带有 \(\texttt{miao.}\)。试判断每一句话是谁说的,或者不能确定某些话是谁说的。

数据范围:\(1\leqslant n\leqslant 10\)。

Solution

直接判断前 \(5\) 个字符和后 \(5\) 个字符即可。需要注意的是,如果出现了像样例中的 \(\texttt{miao.}\) 在开头并且 \(\texttt{lala.}\) 在结尾的一句话,则它也是不确定的。

Code

#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std; int n;
string s; int check1(string s) {
int len = s.size();
if(s[len - 1] == '.' && s[len - 2] == 'a' && s[len - 3] == 'l' && s[len - 4] == 'a' && s[len - 5] == 'l') return 1;
return 0;
}
int check2(string s) {
int len = s.size();
if(s[0] == 'm' && s[1] == 'i' && s[2] == 'a' && s[3] == 'o' && s[4] == '.') return 1;
return 0;
} int main() {
scanf("%d", &n);
getchar(); //避免换行被吃掉
for(int i = 1; i <= n; ++i) {
getline(cin, s);
if((check1(s) && check2(s)) || (!check1(s) && !check2(s))) cout << "OMG>.< I don't know!\n";
else if(check1(s)) cout << "Freda's\n";
else if(check2(s)) cout << "Rainbow's\n";
}
return 0;
}

CF312A Whose sentence is it? 题解的更多相关文章

  1. Codeforces Round #185 (Div. 2) A. Whose sentence is it? 水题

    A. Whose sentence is it? Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...

  2. 2017 google Round D APAC Test 题解

    首先说明一下:我只是用暴力过了4道题的小数据,就是简单的枚举,大数据都不会做!下面的题解,是我从网上搜到的解答以及查看排行榜上大神的答案得出来的. 首先贴一下主要的题解来源:http://codefo ...

  3. HDOJ 4416 Good Article Good sentence

    题解转自:http://blog.csdn.net/dyx404514/article/details/8807440 2012杭州网络赛的一道题,后缀数组后缀自己主动机都行吧. 题目大意:给一个字符 ...

  4. LeetCode All in One题解汇总(持续更新中...)

    突然很想刷刷题,LeetCode是一个不错的选择,忽略了输入输出,更好的突出了算法,省去了不少时间. dalao们发现了任何错误,或是代码无法通过,或是有更好的解法,或是有任何疑问和建议的话,可以在对 ...

  5. Leetcode 简略题解 - 共567题

    Leetcode 简略题解 - 共567题     写在开头:我作为一个老实人,一向非常反感骗赞.收智商税两种行为.前几天看到不止两三位用户说自己辛苦写了干货,结果收藏数是点赞数的三倍有余,感觉自己的 ...

  6. LeetCode 737. Sentence Similarity II

    原题链接在这里:https://leetcode.com/problems/sentence-similarity-ii/ 题目: Given two sentences words1, words2 ...

  7. LeetCode 734. Sentence Similarity

    原题链接在这里:https://leetcode.com/problems/sentence-similarity/ 题目: Given two sentences words1, words2 (e ...

  8. 2016 华南师大ACM校赛 SCNUCPC 非官方题解

    我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...

  9. noip2016十连测题解

    以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #incl ...

随机推荐

  1. Linux学习 - 树莓派4b的U-Boot的初识

    Linux学习 - 树莓派4b的U-Boot的初识 初识U-Boot 学习书籍:<[正点原子]I.MX6U嵌入式Linux驱动开发指南V1.5.1> 章节:第三十章 学习内容: 书中介绍u ...

  2. javascript-初级-day02-this关键字

    day01-获取元素的第二种方法 <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-T ...

  3. cookie的生命周期、访问限制、作用域、prefixes

    cookie的生命周期 cookie的生命周期可以通过两种方式定义: 会话期cookie是最简单的cookie:浏览器关闭后会被自动删除.会话期cookie不需要指定过期时间(Expires)或者有效 ...

  4. confluence——实现

    基于CentOS6.9 [root@localhost ~]# yum install mysql mysql-server -y [root@localhost ~]#yum install -y ...

  5. C++常用的字符串处理函数-全

    这是自己用stl实现的一些字符串处理函数和常用的字符串处理技巧,经验正基本无误,可直接使用,若有问题,可相应列出 包括:split string to int int to string join # ...

  6. (转载)SQL Server 2008 连接JDBC详细图文教程

    点评:SQL Server 2008是目前windows上使用最多的sql数据库,2008的安装机制是基于framework重写的,特点是非常耗时间SQL Server 2008是目前windows上 ...

  7. android studio Please configure Android SDK / please select Android SDK

    有可能是sdk文件损坏造成的. file->settings->appearance&behavior->system settings->android sdk-&g ...

  8. 日常Java测试 2021/11/14

    课堂测试三 package word_show; import java.io.*;import java.util.*;import java.util.Map.Entry; public clas ...

  9. openwrt编译ipk包提示缺少feeds.mk文件

    问题具体表现如下 这个问题困扰了我两个多星期,总算解决了.解决方案如下: 首先,先应该把配置菜单调好. 我的硬件是7620a,要编译的ipk包为helloworld,所以应该使用 make menuc ...

  10. Cocoapods 版本更新与更新到指定版本

    1.本地现有的Cocoapods的版本号是1.1.0.rc.2,想升级到最新版本 1.先切换gem源 gem sources --remove https://rubygems.org/ gem so ...