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 ...
随机推荐
- 查询页面checkbox使用
HTML <input type="checkbox" id="IsChildGroup" name="IsChildGroup" v ...
- eclipse中向左缩进快捷键
总是忘记,还是记下来吧,以后查找方便 Shift + Tab
- git变基--rebase
变基过程: 两个分支 先考虑不用变基的合并: $ git checkout master $ git merge experiment 合并后: 如果变基:(以下为变基过程) $ git checko ...
- hdu_2899_Strange fuction(三分查找)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2899 题意:让你解方程 题解:对于只有一个凸或者没有凸的图像,可以直接上三分解决. #include& ...
- C语言strtok()函数:字符串分割
头文件:#include <string.h> 定义函数:char * strtok(char *s, const char *delim); 函数说明:strtok()用来将字符串分割成 ...
- 在C#中使用反射调用internal的方法
MSDN上解释Internal如下: The internal keyword is an access modifier for types and type members. Internal t ...
- frameset框架样式 加边框
<frameset rows="580,*" FRAMESPACING="3"> <frame noresize name="Top ...
- Inno Setup入门(二十)——Inno Setup类参考(6)
存储框 存储框也是典型的窗口可视化组件,同编辑框类似,可以输入.显示文本,但是和编辑框不同的是,编辑框只能编辑.显示单行文本,而存储框则可以对多行文本进行操作.存储框的类定义如下:< xmlna ...
- iptables基础知识
iptables防火墙可以用于创建过滤(filter)与NAT规则.所有Linux发行版都能使用iptables,因此理解如何配置 iptables将会帮助你更有效地管理Linux防火墙.如果你是第一 ...
- 3.1 cron表达式
1.Cron在线生成网址: http://cron.qqe2.com/ http://www.pdtools.net/tools/becron.jsp#cron 2.Cron 概要 3. ...