Alphabet Tiles

AtCoder
IDabc358_e
Time2000ms
Memory256MB
Difficulty
> AtCoder Land sells tiles with English letters written on them. Takahashi is thinking of making a nameplate by arranging these tiles in a row. Find the number, modulo $998244353$, of strings consisting of uppercase English letters with a length between $1$ and $K$, inclusive, that satisfy the following conditions: * For every integer $i$ satisfying $1 \leq i \leq 26$, the following holds: * Let $a_i$ be the $i$\-th uppercase English letter in lexicographical order. For example, $a_1 = $ `A`, $a_5 = $ `E`, $a_{26} = $ `Z`. * The number of occurrences of $a_i$ in the string is between $0$ and $C_i$, inclusive. ## Constraints * $1 \leq K \leq 1000$ * $0 \leq C_i \leq 1000$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $K$ $C_1$ $C_2$ $\ldots$ $C_{26}$ [samples]
Samples
Input #1
2
2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Output #1
10

The $10$ strings that satisfy the conditions are `A`, `B`, `C`, `AA`, `AB`, `AC`, `BA`, `BC`, `CA`, `CB`.
Input #2
358
1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Output #2
64
Input #3
1000
1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000
Output #3
270274035
API Response (JSON)
{
  "problem": {
    "name": "Alphabet Tiles",
    "description": {
      "content": "> AtCoder Land sells tiles with English letters written on them. Takahashi is thinking of making a nameplate by arranging these tiles in a row. Find the number, modulo $998244353$, of strings consist",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc358_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "> AtCoder Land sells tiles with English letters written on them. Takahashi is thinking of making a nameplate by arranging these tiles in a row.\n\nFind the number, modulo $998244353$, of strings consist...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments