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 ...
随机推荐
- RESTful架构2--架构详解
转自:RESTful架构详解 1. 什么是REST REST全称是Representational State Transfer,中文意思是表述(编者注:通常译为表征)性状态转移. 它首次出现在200 ...
- 安装 svn
rpm -qa subversion yum install subversion svnserve --version 创建仓库目录例如: mkdir /home/svn/game 创建项目 svn ...
- Number-guessing Game
Number-guessing Game Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Othe ...
- python常用操作
1.进入python命令行: #python >>>... 退出python命令行 >>>exit() #... 2.运行1.py 直接运行1.py: #pytho ...
- 今天遇到了隐藏顶部菜单栏(top bar)的菜鸟问题,解决了。
self.navigationController.navigationBarHidden = YES; http://stackoverflow.com/questions/3397381/hide ...
- Windows中安装jdk,出现javac不是内部或外部命令 也不是可运行的程序
在经过多次实验,终于解决了在dos窗口验证jdk是否安装成功的错误提示-----javac不是内部或外部命令 也不是可运行的程序 首先要明确的是 在新建 JAVA_HOME , CLASSPATH文件 ...
- PHP正则表达式试题
1.POSIX正则表达式扩展在PHP哪个版本被废弃了 2.请写出匹配任意数字,任意空白字符,任意单词字符的符号? 3.执行一个正则表达式匹配的函数是什么?返回的结果有哪些? 4.执行一个全局正则表达式 ...
- 解读QML之三
QML语法 1.QML基本语法 1.1导入声明 导入声明允许客户端告诉QML引擎可以在QML文档中使用哪些模块,JavaScript资源以及组件目录.文档中可以使用的类型依赖于在文档中导入的模块.资源 ...
- IOS传值之Block传值(二)
@interface QWViewController : UIViewController @property(nonatomic,strong)UILabel *label; @property( ...
- 笨方法学python--变量和命名
1 =(单等号)和==(双等号)的区别 =用来赋值, ==用来判断是否相等 2 x = 100 在操作符2侧加空格,易读 3 打印时,进行字符串拼接 print "there are&quo ...