A. Way Too Long Words

Codeforces
IDCF71A
Time1000ms
Memory256MB
Difficulty
strings
English · Original
Chinese · Translation
Formal · Original
Sometimes some words like "_localization_" or "_internationalization_" are so long that writing them many times in one text is quite tiresome. Let's consider a word _too long_, if its length is **strictly more** than 10 characters. All too long words should be replaced with a special abbreviation. This abbreviation is made like this: we write down the first and the last letter of a word and between them we write the number of letters between the first and the last letters. That number is in decimal system and doesn't contain any leading zeroes. Thus, "_localization_" will be spelt as "_l10n_", and "_internationalization_» will be spelt as "_i18n_". You are suggested to automatize the process of changing the words with abbreviations. At that all too long words should be replaced by the abbreviation and the words that are not too long should not undergo any changes. ## Input The first line contains an integer _n_ (1 ≤ _n_ ≤ 100). Each of the following _n_ lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters. ## Output Print _n_ lines. The _i_\-th line should contain the result of replacing of the _i_\-th word from the input data. [samples]
有时一些单词如 "_localization_" 或 "_internationalization_" 过于冗长,在一篇文章中多次书写它们相当繁琐。 如果一个单词的长度 *严格大于* #cf_span[10] 个字符,则称其为 _过长单词_。所有过长单词都应被替换为一个特殊的缩写。 这种缩写的构造方式如下:我们写出单词的第一个字母和最后一个字母,并在它们之间写下第一个字母与最后一个字母之间的字母数量。这个数量以十进制表示,且不包含前导零。 因此,"_localization_" 将被拼写为 "_l10n_",而 "_internationalization_" 将被拼写为 "_i18n_"。 请你自动化将单词替换为缩写的过程。所有过长单词都应被缩写,而非过长单词则保持不变。 第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 100])。接下来的 #cf_span[n] 行每行包含一个单词。所有单词均由小写拉丁字母组成,长度范围为 #cf_span[1] 到 #cf_span[100] 个字符。 请输出 #cf_span[n] 行。第 #cf_span[i]-th 行应包含输入数据中第 #cf_span[i]-th 个单词的替换结果。 ## Input 第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 100])。接下来的 #cf_span[n] 行每行包含一个单词。所有单词均由小写拉丁字母组成,长度范围为 #cf_span[1] 到 #cf_span[100] 个字符。 ## Output 请输出 #cf_span[n] 行。第 #cf_span[i]-th 行应包含输入数据中第 #cf_span[i]-th 个单词的替换结果。 [samples]
**Definitions** Let $ n \in \mathbb{Z} $ be the number of words. Let $ W = (w_1, w_2, \dots, w_n) $ be a sequence of words, where each $ w_i $ is a string over the lowercase Latin alphabet, and $ 1 \leq |w_i| \leq 100 $. **Constraints** $ 1 \leq n \leq 100 $ **Objective** For each word $ w_i $, define the output $ o_i $ as: $$ o_i = \begin{cases} w_i, & \text{if } |w_i| \leq 10 \\ w_i[0] + (|w_i| - 2) + w_i[|w_i|-1], & \text{if } |w_i| > 10 \end{cases} $$ where $ w_i[0] $ is the first character, $ w_i[|w_i|-1] $ is the last character, and $ |w_i| - 2 $ is the integer representing the count of letters between them (in decimal, no leading zeros). Output the sequence $ (o_1, o_2, \dots, o_n) $.
Samples
Input #1
4
word
localization
internationalization
pneumonoultramicroscopicsilicovolcanoconiosis
Output #1
word
l10n
i18n
p43s
API Response (JSON)
{
  "problem": {
    "name": "A. Way Too Long Words",
    "description": {
      "content": "Sometimes some words like \"_localization_\" or \"_internationalization_\" are so long that writing them many times in one text is quite tiresome. Let's consider a word _too long_, if its length is **str",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF71A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Sometimes some words like \"_localization_\" or \"_internationalization_\" are so long that writing them many times in one text is quite tiresome.\n\nLet's consider a word _too long_, if its length is **str...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "有时一些单词如 \"_localization_\" 或 \"_internationalization_\" 过于冗长,在一篇文章中多次书写它们相当繁琐。\n\n如果一个单词的长度 *严格大于* #cf_span[10] 个字符,则称其为 _过长单词_。所有过长单词都应被替换为一个特殊的缩写。\n\n这种缩写的构造方式如下:我们写出单词的第一个字母和最后一个字母,并在它们之间写下第一个字母与最后一个字母之间的字...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the number of words.  \nLet $ W = (w_1, w_2, \\dots, w_n) $ be a sequence of words, where each $ w_i $ is a string over the lowercase Latin alphabet, and $ ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments