Files
PAT/html/a1077.html
T

37 lines
1.5 KiB
HTML

<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h1>1077. Kuchiguse (20)</h1>
<div id="problemContent">
<p>
The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is often exaggerated artistically in Anime and Manga. For example, the artificial sentence ending particle "nyan~" is often used as a stereotype for characters with a cat-like personality:</p>
<li>Itai nyan~ (It hurts, nyan~)</li>
<li>Ninjin wa iyada nyan~ (I hate carrots, nyan~)</li>
<p>
Now given a few lines spoken by the same character, can you find her Kuchiguse?</p>
<p><b>
Input Specification:
</b></p>
<p>Each input file contains one test case. For each case, the first line is an integer N (2&lt;=N&lt;=100). Following are N file lines of 0~256 (inclusive) characters in length, each representing a character's spoken line. The spoken lines are case sensitive.</p>
<p><b>
Output Specification:
</b></p>
<p>For each test case, print in one line the kuchiguse of the character, i.e., the longest common suffix of all N lines. If there is no such suffix, write "nai".</p>
<b>Sample Input 1:</b><pre>
3
Itai nyan~
Ninjin wa iyadanyan~
uhhh nyan~
</pre>
<b>Sample Output 1:</b><pre>
nyan~
</pre>
<b>Sample Input 2:</b><pre>
3
Itai!
Ninjinnwaiyada T_T
T_T
</pre>
<b>Sample Output 2:</b><pre>
nai
</pre>
</div>