2 2
5
When $N = 2$, there are two possible permutations $P$: $(1,2),(2,1)$.
The score of the permutation $(1,2)$ is found as follows.
* Initially, Person $1$ has Ball $1$, and Person $2$ has Ball $2$.
After Snuke's first scream, Person $1$ has Ball $1$, and Person $2$ has Ball $2$.
Here, every Person $i$ has Ball $i$, so he stops screaming.
Thus, the score is $1$.
The score of the permutation $(2,1)$ is found as follows.
* Initially, Person $1$ has Ball $1$, and Person $2$ has Ball $2$.
After Snuke's first scream, Person $1$ has Ball $2$, and Person $2$ has Ball $1$.
After Snuke's second scream, Person $1$ has Ball $1$, and Person $2$ has Ball $2$.
Here, every Person $i$ has Ball $i$, so he stops screaming.
Thus, the score is $2$.
Therefore, the answer in this case is $1^2 + 2^2 = 5$.3 3
79 All permutations and their scores are listed below. * $(1,2,3)$: The score is $1$. * $(1,3,2)$: The score is $2$. * $(2,1,3)$: The score is $2$. * $(2,3,1)$: The score is $3$. * $(3,1,2)$: The score is $3$. * $(3,2,1)$: The score is $2$. Thus, we should print $1^3 + 2^3 + 2^3 + 3^3 + 3^3 + 2^3 = 79$.
50 10000
77436607
{
"problem": {
"name": "Score of Permutations",
"description": {
"content": "For a permutation $P = (p_1, p_2, \\dots, p_N)$ of $(1,2, \\dots, N)$, let us define the score $S(P)$ of $P$ as follows. * There are $N$ people, numbered $1,2,\\dots,N$. Additionally, Snuke is there. ",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc226_f"
},
"statements": [
{
"statement_type": "Markdown",
"content": "For a permutation $P = (p_1, p_2, \\dots, p_N)$ of $(1,2, \\dots, N)$, let us define the score $S(P)$ of $P$ as follows.\n\n* There are $N$ people, numbered $1,2,\\dots,N$. Additionally, Snuke is there. ...",
"is_translate": false,
"language": "English"
}
]
}