1077 Kuchiguse (20 分)
 

The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is often exaggerated artistically in Anime and Manga. For example, the artificial sentence ending particle "nyan~" is often used as a stereotype for characters with a cat-like personality:

  • Itai nyan~ (It hurts, nyan~)

  • Ninjin wa iyada nyan~ (I hate carrots, nyan~)

Now given a few lines spoken by the same character, can you find her Kuchiguse?

Input Specification:

Each input file contains one test case. For each case, the first line is an integer N (2). Following are N file lines of 0~256 (inclusive) characters in length, each representing a character's spoken line. The spoken lines are case sensitive.

Output Specification:

For each test case, print in one line the kuchiguse of the character, i.e., the longest common suffix of all N lines. If there is no such suffix, write nai.

Sample Input 1:

3
Itai nyan~
Ninjin wa iyadanyan~
uhhh nyan~

Sample Output 1:

nyan~

Sample Input 2:

3
Itai!
Ninjinnwaiyada T_T
T_T

Sample Output 2:

nai
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; int main(){ int t;scanf("%d",&t);
vector<string> vec;
int minlenn = INT_MAX;
string temp;getline(cin,temp);
while(t--){
string s;getline(cin,s);
string temp="";
for(int i=;i < s.size();i++){
temp = s[i]+temp;
}
vec.push_back(temp);
int len = s.size();
minlenn = min(minlenn,len); //直接把s.size()放进去不对???
}
// cout << vec.size(); string res = "";
for(int i=;i < minlenn;i++){
char sx = vec[][i];
bool flag = ;
for(int j=;j < vec.size();j++){
if(vec[j][i] != sx){
flag = ;
break;
}
}
if(flag){
res = sx+res;
}
else break;
}
if(res == "")cout << "nai";
else cout << res; return ;
}

——遇到情况多样的题目,可以大胆的猜测,只要先过样例就行。

在getline前如果有cin 会读取结尾的\0

PAT 1077 Kuchiguse的更多相关文章

  1. PAT 1077 Kuchiguse [一般]

    1077 Kuchiguse (20 分) The Japanese language is notorious for its sentence ending particles. Personal ...

  2. pat 1077 Kuchiguse(20 分) (字典树)

    1077 Kuchiguse(20 分) The Japanese language is notorious for its sentence ending particles. Personal ...

  3. PAT甲1077 Kuchiguse【字符串】【暴力】【Hash】【二分】

    1077 Kuchiguse (20 分) The Japanese language is notorious for its sentence ending particles. Personal ...

  4. 1077. Kuchiguse (20)【字符串处理】——PAT (Advanced Level) Practise

    题目信息 1077. Kuchiguse (20) 时间限制100 ms 内存限制65536 kB 代码长度限制16000 B The Japanese language is notorious f ...

  5. PAT 甲级 1077 Kuchiguse (20 分)(简单,找最大相同后缀)

    1077 Kuchiguse (20 分)   The Japanese language is notorious for its sentence ending particles. Person ...

  6. 1077 Kuchiguse (20 分)

    1077 Kuchiguse (20 分) The Japanese language is notorious for its sentence ending particles. Personal ...

  7. PAT 1077. 互评成绩计算

    PAT 1077. 互评成绩计算 在浙大的计算机专业课中,经常有互评分组报告这个环节.一个组上台介绍自己的工作,其他组在台下为其表现评分.最后这个组的互评成绩是这样计算的:所有其他组的评分中,去掉一个 ...

  8. PAT 甲级 1077 Kuchiguse

    https://pintia.cn/problem-sets/994805342720868352/problems/994805390896644096 The Japanese language ...

  9. PAT Advanced 1077 Kuchiguse (20 分)

    The Japanese language is notorious for its sentence ending particles. Personal preference of such pa ...

随机推荐

  1. Kali2安装完成后的设置

    1.安装中文输入法 vim /etc/apt/sources.list 全部删除,改为国内源 #中科大 deb http://mirrors.ustc.edu.cn/kali kali-rolling ...

  2. 接口测试工具-Jmeter使用笔记(九:跨线程组传递变量)

    使用场景: 请求API需要授权令牌,但是授权令牌只需要获取一次,即可调用服务器上其他业务接口. 所以我想要把授权操作放在单独的一个线程,业务流放在其他线程. 这就需要我把从授权线程获取的令牌传入业务流 ...

  3. python框架之Django(12)-认证系统之auth模块

    我们在开发一个网站的时候,无可避免的需要设计实现网站的用户系统.此时我们需要实现包括用户注册.用户登录.用户认证.注销.修改密码等功能,这还真是个麻烦的事情呢. Django作为一个完美主义者的终极框 ...

  4. 三、UI开发之核心基础——约束(入门)

    先学个新技能:添加图片控件Image View iOS的图片控件是ImageView,ImageView通过提前载入用户指定的图片资源来显示相应的图片. 所以图片控件的关键信息有3个: 1. Imag ...

  5. Python记录9:函数4:名称空间作用域+闭包函数+装饰器

    ''' 一: 名称空间namespaces     名称空间就是存放名字与值绑定关系的内存空间 二: 名称空间分为三种     内置名称空间:         1. 特点: 存放是python解释器自 ...

  6. COM中参数标识

  7. 【Spark-core学习之八】 SparkShuffle & Spark内存管理

    [Spark-core学习之八] SparkShuffle & Spark内存管理环境 虚拟机:VMware 10 Linux版本:CentOS-6.5-x86_64 客户端:Xshell4 ...

  8. Java复制目录/子目录/文件

    import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import ja ...

  9. nor flash与nand flash启动的简单比较--APPLE的ARM学习笔记一

    2010-10-08 22:26:00 A,nor flash与nand flash的一些区别 1)接口区别: NOR FLASH地址线和数据线分开,来了地址和控制信号,数据就出来. NAND Fla ...

  10. 用java 集合和映射实现文章的单词数目统计

    package 一_统计字母出现; import java.io.File; import java.io.FileNotFoundException; import java.util.HashMa ...