cswork / OA打开练习工作台

MicrosoftOA #55

Prepare Notification

估计简单可在线判题

考点(AI 标注)字符串

A message consists of English words separated by single spaces. If it exceeds K characters, delete some whole words from the end and append " ..." (a space followed by three ASCII periods); if no word can be kept, show only "...". Find the longest valid notification. The source's examples were inconsistent about the space before the ellipsis, so this site corrected them by the single-space rule stated in the statement.

This site uses a standard input/output protocol.

输入格式

The first line contains K (3..500), and the second line contains message (1..500 characters), consisting only of English letters and spaces, with no leading, trailing, or consecutive spaces.

输出格式

Output the full notification followed by a terminating newline.

样例 1

输入:

15
And now here is my secret

输出:

And now ...

样例 2

输入:

4
super dog

输出:

...

样例 3

输入:

20
how are you

输出:

how are you

样例说明

Example 1: keep And now, then append a space and three periods, outputting "And now ..."; also keeping here would make the length 16. Example 2: any word plus the suffix exceeds 4, so only "..." is possible. Example 3: the whole sentence has length 11, which does not exceed 20, so it is returned unchanged.