問題一覧 > 通常問題

No.2216 Pa1indr0me

レベル : / AI推定難易度 : 1025 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 186
作問者 : stoq / テスター : ekaraage Shirotsume
お気に入りにしたユーザー ProblemId : 7702 / 自分の提出
問題文最終更新日: 2023-02-18 08:27:29
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 377 (順位表) の他の問題:

Problem Statement

Suppose you make a string $S$ of length $2N$ by arranging $N$ copies of '0' and $N$ copies of '1' in any order. What is the maximum possible number of non-empty contiguous substrings of $S$ that are palindromes?
Here, substrings are distinguished by the positions from which they are taken.

Answer $T$ test cases.

Input

$T$
$N_1$
$\vdots$
$N_T$

  • All input values are integers.
  • $1 \leq T \leq 100$
  • $1 \leq N_i \leq 10^9$

Output

For each $i = 1,2,\dots,T$, output on the $i$-th line the answer to the problem for $N=N_i$.

Sample

Sample 1
Input
4
1
2
34
567891011
Output
2
6
1190
322500200942493132

In the $1$-st test case, for example, taking $S= \mathsf {01}$ gives $2$ palindromic contiguous substrings, and this is the maximum.

In the $2$-nd test case, for example, taking $S= \mathsf {0110}$ gives $6$ palindromic contiguous substrings, and this is the maximum.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。