📄 d.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0044)http://plg.uwaterloo.ca/~acm00/010602/D.html -->
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=GB18030">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY><IMG src="D.files/zipf.gif" align=right>
<H3>Problem D - Zipf's Law</H3>Harvard linguistics professor George Kingsley
Zipf (1902-1950) observed that the frequency of the <I>k</I>th most common word
in a text is roughly proportional to 1/<I>k</I>. He justified his observations
in a book titled <I>Human behavior and the principle of least effort</I>
published in 1949. While Zipf's rationale has largely been discredited, the
principle still holds, and others have afforded it a more sound mathematical
basis.
<P>You are to find all the words occurring <EM>n</EM> times in an English text.
A word is a sequence of letters. Words are separated by non-letters.
Capitalization should be ignored. A word can be of any length that an English
word can be.
<H3>Input</H3>Input consists of several test cases. The first line of each case
contains a single positive integer <EM>n</EM>. Several lines of text follow
which will contain no more than 10000 words. The text for each case is
terminated by a single line containing EndOfText. EndOfText does not appear
elsewhere in the input and is not considered a word.
<H3>Output</H3>For each test case, output the words which occur <EM>n</EM> times
in the input text, one word per line, lower case, in alphabetical order. If
there are no such words in input, output the following line: <PRE>There is no such word.
</PRE>Leave a blank line between cases.
<H3>Sample Input</H3><PRE>2
In practice, the difference between theory and practice is always
greater than the difference between theory and practice in theory.
- Anonymous
Man will occasionally stumble over the truth, but most of the
time he will pick himself up and continue on.
- W. S. L. Churchill
EndOfText
</PRE>
<H3>Output for Sample Input</H3><PRE>between
difference
in
will
</PRE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -