最长公共后缀。暴力。

#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)的更多相关文章

  1. PTA (Advanced Level)1077.Kuchiguse

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

  2. PAT (Advanced Level) 1061. Dating (20)

    简单模拟. #include<stdio.h> #include<string.h> ],s2[],s3[],s4[]; ][]={"MON ", &quo ...

  3. PAT (Advanced Level) 1008. Elevator (20)

    简单模拟. 注意a[i]==a[i-1]的情况. #include<iostream> #include<cstring> #include<cmath> #inc ...

  4. PAT (Advanced Level) 1035. Password (20)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  5. 【PAT甲级】1077 Kuchiguse (20 分)(cin.ignore()吃掉输入n以后的回车接着用getine(cin,s[i])输入N行字符串)

    题意: 输入一个正整数N(<=100),接着输入N行字符串.输出N行字符串的最长公共后缀,否则输出nai. AAAAAccepted code: #include<bits/stdc++. ...

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

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

  7. PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642 题目描述: The task is really simple: ...

  8. PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642 题目描述: Shuffling is a procedure us ...

  9. 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 ...

随机推荐

  1. hdu_5763_Another Meaning(dp)

    题目链接:hdu_5763_Another Meaning 题意: 一个文本串A,一个模式串B,如果文本串含有模式串B,那么就能组合成多种意思,如下: In the first case, “ heh ...

  2. servlet第2讲(下集)----通过HttpServlet实现一个用户登录网站(继承HttpServlet)

    1.计划框架 2.先建立Login的servlet (1)建立Login,编写代码,进行编译     (2)配置web.xml (3)重新加载,并且验证 (4)解决乱码问题 (5)再次加载,然后验证 ...

  3. flashbuilder mx组件 MenuBar

    来源:http://www.cuplayer.com/player/PlayerCode/Flex/2013/0118661.html <fx:Script> <![CDATA[ i ...

  4. cornerstone 怎么使用

    Cornerstone的逻辑很清晰,界面打开后,左边栏上下分开,上面是working copies的列表,下面是REPOSITORIES的列表.常见的功能基本上跟windows一样,在上下文中可以得到 ...

  5. laravel多种安装方法

    首先请确保环境为 PHP >= 5.5.9 OpenSSL PHP 扩展 PDO PHP 扩展 Mbstring PHP 扩展 Tokenizer PHP 扩展 方法一: 直接下载安装好的lar ...

  6. iOS8.0以后的相册

    在 iOS 8.0 后, 使用the Photos framework 代替 the Assets Library framework , The Photos framework 提供更特色和更好的 ...

  7. Swift 学习笔记 (二)

    原创:转载请注明出处 41.闭包表达式语法(Closure Expression Syntax) 闭包表达式语法有如下一般形式: { (parameters) -> returnType in ...

  8. 后台如何解析json

    1.以前倒是没有怎没遇到过需要后台解析的,由于json传到后台实际上是传的一个字符串通常用到批量删除时 var rows = $('#tt').datagrid('getSelections'); v ...

  9. HDU2579--Dating with girls(2)--(DFS, 判重)

    Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  10. haxe 嵌入swf 读取里面的内容

    首先安装 swf 库,运行命令: 命令提示符: haxelib install swf 在project.xml 加上 <!-- 导入swf类库 --> <haxelib name= ...