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 ...
随机推荐
- thinkphp的目录结构设计经验总结
用thinkphp开发了好些项目了:最近准备抽空写一些经验总结: 希望能给刚开始接触tp的童鞋们提供一些开发的方案:少走一些弯路:少踩一些坑: 这些绝对都是些精华干货:耐着性子阅读:相信肯定是会有收获 ...
- Android 面试题(转)
转自:http://www.jobui.com/mianshiti/it/android/2682/ 1. Android dvm的进程和Linux的进程, 应用程序的进程是否为同一个概念DVM指da ...
- mib.c
函数 sprint_realloc_by_type (E:\code\net-snmp-5.4.2.1\snmplib\mib.c)的主要作用是: 解析传入的mib中的节点,根据mib节点类型,将其 ...
- LeetCode OJ 160. Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...
- dns是什么
域名解析服务器,靠它把你要访问的网址找到然后把信息送到你电脑上.DNS 是域名系统 (Domain Name System) 的缩写,它是由解析器和域名服务器组成的.域名服务器是指保存有该网络中所有主 ...
- WebForm(aspx,cs,dll之间的关系)
WebForm分为两个文件aspx和aspx.cs,aspx是页面模板,是页面描述文件,就是html的内容,和aspx结合的更好,不用像一开始那样程序员自己去填充模板,控件都是定义在aspx中,内联的 ...
- laravel路由使用【总结】
1.路由参数 必选参数 有时我们需要在路由中捕获 URI 片段.比如,要从 URL 中捕获用户 ID,需要通过如下方式定义路由参数: Route::get('/test_param/{id}', 'T ...
- 7z 的命令行
用于压缩和解压缩 来源:http://blog.csdn.net/shuckstark/article/details/7598443 挺有用的东西,写脚本时用处多多, 7z.exe和7za.exe ...
- 一篇非常适合git入门的文章
http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137583770360579 ...
- poi 合并单元格、设置边框
HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(); //创建一个样式 HSSFCellStyle sty ...