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. 动画录屏软件-LICEcap

    越来越觉得脑子不够用了,不记博客根本找不到自己以前都干了些啥,自己学的东西用不到就特别难受,学完不用,重新捡起来跟嚼蜡一样难受. 接下来推荐一款动画截屏软件,短小精悍: https://www.coc ...

  2. Windwos安装Node.js和npm的详细步骤

    How to Install Node.js and NPM on Windows Node.js和npm 安装 Node.js 的时候会自动安装 npm ,并且 npm 就是 Node.js 的包管 ...

  3. 统计学习2:线性可分支持向量机(Scipy实现)

    1. 模型 1.1 超平面 我们称下面形式的集合为超平面 \[\begin{aligned} \{ \bm{x} | \bm{a}^{T} \bm{x} - b = 0 \} \end{aligned ...

  4. CF1418G Three Occurrences

    统计满足某些性质的区间个数. 我们考虑移动 \(r\) 指针. 然后考虑把不能选的区间 \(ban\)掉. 具体看下细节吧. #include<iostream> #include< ...

  5. Atcoder Grand Contest 023 E - Inversions(线段树+扫描线)

    洛谷题面传送门 & Atcoder 题面传送门 毒瘤 jxd 作业-- 首先我们不能直接对所有排列计算贡献对吧,这样复杂度肯定吃不消,因此我们考虑对每两个位置 \(x,y(x<y)\), ...

  6. nginx_日志切割脚本

    #!/bin/bash NGINX_LOG=/usr/loca/nginx/logs/access.log RE_LOG=/data/backup/`data +%Y%m%d` echo -e &qu ...

  7. Excel-统计各分数段人数 frequency()

    FREQUENCY函数 函数名称:FREQUENCY 主要功能:以一列垂直数组返回某个区域中数据的频率分布. 使用格式:FREQUENCY(data_array,bins_array) 参数说明:Da ...

  8. SpringBoot 整合 MyBatis,实现 CRUD 示例

    目录 前言 创建项目/模块 SpringBoot Console Application CommandLineRunner SpringBoot 集成 MyBatis 创建数据库/表 配置数据源/连 ...

  9. 前端2 — CSS — 更新完毕

    1.CSS是什么? 指:Cascading Style Sheet  --- 层叠样式表 CSS 即:美化网页( 在HTML不是说过W3C规定网页为三种标准嘛,结构层HTML已经玩了,而这个CSS就是 ...

  10. h5移动端设备像素比dpr介绍

    首先介绍一下概念 devicePixelRatio其实指的是window.devicePixelRatio window.devicePixelRatio是设备上物理像素和设备独立像素(device- ...