| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 16 | 3 | 3 | 100.000% |
Little Square found an array $a$ consisting of $N$ positive numbers formed of nonzero digits. He can replace any number from $a$ with another number consisting of as many digits, all nonzero.
After making all the changes he wants, Little Square will form a new number $M$ by writing the elements of the array $a$ in order, without spaces. What is the minimum numbers of elements of the array $a$ which need to be replaced by Little Square for the number $M$ obtained to be a palindrome.
The first line of standard input will contain an integer $N,ドル the size of the array $a$. The second line will contain $N$ integers consisting only of nonzero digits representing the array $a$.
Attention! The numbers read from the input file may be too big for the int data type. It is recommended to use the long long data type.
The standard output will contain only one integer, representing the minimum number of elements of the array a that need to be replaced.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 10 | 1ドル ≤ a_i ≤ 9,ドル for every 1ドル ≤ i ≤ N$ |
| 2 | 10 | 1ドル ≤ N ≤ 16$ |
| 3 | 15 | 1ドル ≤ N ≤ 32$ |
| 4 | 20 | 1ドル ≤ N ≤ 1000$ |
| 5 | 10 | $M$ can become a palindrome by replacing at most 2ドル$ numbers. |
| 6 | 35 | No additional constraints. |
6 13577 98 348 997 8 31
2
3 455 21 1347742112664
1
In the first example, Little Square can replace the first number with 13879ドル$ and the third number with 448ドル$. The number $M$ will become 1387998448997831ドル$ which is a palindrome. There is no solution with less than two replacements.
In the second example, Little Square can replace the third number with 1347743112554ドル$.