PAT (Advanced Level) 1077. Kuchiguse (20)
最长公共后缀。暴力。
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>
using namespace std; char s[][];
int len[];
int n; int main()
{
memset(s,,sizeof s);
scanf("%d",&n);
getchar();
for(int i=; i<=n; i++) gets(s[i]);
for(int i=; i<=n; i++) len[i]=strlen(s[i]); for(int i=; i<=n; i++)
{
for(int j=; j<len[i]/; j++)
swap(s[i][j],s[i][len[i]-j-]);
} bool fail=;
for(int j=;s[][j]; j++)
{
for(int i=; i<=n; i++)
if(s[i][j]!=s[i-][j]) fail=;
if(fail==)
{
if(j==) printf("nai\n");
else
{
for(int k=j-; k>=; k--)
printf("%c",s[][k]);
printf("\n");
}
break;
}
} if(fail==)
{
for(int k=len[]-; k>=; k--)
printf("%c",s[][k]);
printf("\n");
}
return ;
}
PAT (Advanced Level) 1077. Kuchiguse (20)的更多相关文章
- PTA (Advanced Level)1077.Kuchiguse
The Japanese language is notorious for its sentence ending particles. Personal preference of such pa ...
- PAT (Advanced Level) 1061. Dating (20)
简单模拟. #include<stdio.h> #include<string.h> ],s2[],s3[],s4[]; ][]={"MON ", &quo ...
- PAT (Advanced Level) 1008. Elevator (20)
简单模拟. 注意a[i]==a[i-1]的情况. #include<iostream> #include<cstring> #include<cmath> #inc ...
- PAT (Advanced Level) 1035. Password (20)
简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...
- 【PAT甲级】1077 Kuchiguse (20 分)(cin.ignore()吃掉输入n以后的回车接着用getine(cin,s[i])输入N行字符串)
题意: 输入一个正整数N(<=100),接着输入N行字符串.输出N行字符串的最长公共后缀,否则输出nai. AAAAAccepted code: #include<bits/stdc++. ...
- 1077. Kuchiguse (20)【字符串处理】——PAT (Advanced Level) Practise
题目信息 1077. Kuchiguse (20) 时间限制100 ms 内存限制65536 kB 代码长度限制16000 B The Japanese language is notorious f ...
- PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642
PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642 题目描述: The task is really simple: ...
- PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642
PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642 题目描述: Shuffling is a procedure us ...
- PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642
PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642 题目描述: Being unique is so important to peo ...
随机推荐
- OpenCV成长之路:图像直方图的应用
OpenCV成长之路:图像直方图的应用 2014-04-11 13:57:03 标签:opencv 图像 直方图 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否 ...
- hdu_3068_最长回文(Manacher)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3068 题意:给你一个字符串,让你求最长的回文子串. 题解:数据量比较大,暴力O(n2)会超时,直接上马 ...
- 根据字符串获取对应类型(Type) 转
public static Type GetTypeByString(string type) { switch (type.ToLower()) ...
- Spring Security3实现,权限动态获取
Spring Security3实现,权限动态获取 原文 http://blog.csdn.net/yangwei19680827/article/details/9359113 主题 网络安全Sp ...
- JSP基础语法--跳转指令 jsp:forward page
带参数的跳转指令: <jsp:forward page="{路径|<%=表达式%>}"/> <jsp:param name="参数名称&qu ...
- 关于Select * 与Select 字段名 的问题!
[转]http://blog.csdn.net/tongyu2009/article/details/8252418 1.SELECT * 语句取出表中的所有字段,不论该字段的数据对调用的应用程序是否 ...
- centos 6.5常见lib库安装
在CentOS安装软件的时候,可能缺少一部分支持库,而报错.这里首先安装系统常用的支持库.那么在安装的时候就会减少很多的错误的出现. # yum install -y gcc gdb strace g ...
- 一篇非常适合git入门的文章
http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137583770360579 ...
- 【一题多解】 map 二分 hash trie poj 2503
各种方式解这道题!! 利用map 超时了 #include <iostream> #include <string> #include <map> using na ...
- merge 语句的语法
/*Merge into 详细介绍 MERGE语句是Oracle9i新增的语法,用来合并UPDATE和INSERT语句. 通过MERGE语句,根据一张表或子查询的连接条件对另外一张表进行查询, 连接条 ...