4 4320
2 For $P=(4,2,3,1)$, we have $s _ 4\times10 ^ 3+s _ 2\times10 ^ 2+s _ 3\times10 ^ 1+s _ 1=324=18 ^ 2$. For $P=(3,2,4,1)$, we have $s _ 3\times10 ^ 3+s _ 2\times10 ^ 2+s _ 4\times10 ^ 1+s _ 1=2304=48 ^ 2$. No other permutations result in square numbers, so you should print $2$.
3 010
2
For $P=(1,3,2)$ or $P=(3,1,2)$, we have $\displaystyle\sum _ {i=1} ^ Ns _ {p _ i}10 ^ {N-i}=1=1 ^ 2$.
For $P=(2,1,3)$ or $P=(2,3,1)$, we have $\displaystyle\sum _ {i=1} ^ Ns _ {p _ i}10 ^ {N-i}=100=10 ^ 2$.
No other permutations result in square numbers, so you should print $2$. Note that different permutations are not distinguished if they result in the same number.13 8694027811503
840
{
"problem": {
"name": "Square Permutation",
"description": {
"content": "You are given a string $S$ of length $N$ consisting of digits. Find the number of square numbers that can be obtained by interpreting a permutation of $S$ as a decimal integer. More formally, solve th",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 4000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc324_d"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You are given a string $S$ of length $N$ consisting of digits.\nFind the number of square numbers that can be obtained by interpreting a permutation of $S$ as a decimal integer.\nMore formally, solve th...",
"is_translate": false,
"language": "English"
}
]
}