AtCoder Grand Contest 036
F
Square Constraints
AtCoder
⌀ 3783
原题
← E→
翻译中…

Problem Statement

翻译中…

Given is an integer $N$. How many permutations $(P_0,P_1,\cdots,P_{2N-1})$ of $(0,1,\cdots,2N-1)$ satisfy the following condition?

翻译中…
  • For each $i$ $(0 \leq i \leq 2N-1)$, $N^2 \leq i^2+P_i^2 \leq (2N)^2$ holds.
翻译中…

Since the number can be enormous, compute it modulo $M$.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 250$
  • $2 \leq M \leq 10^9$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N M

翻译中…

Output

翻译中…

Print the number of permutations that satisfy the condition, modulo $M$.

翻译中…

样例

Input #1
2 998244353
Output #1
4
Four permutations satisfy the condition: - $(2,3,0,1)$ - $(2,3,1,0)$ - $(3,2,0,1)$ - $(3,2,1,0)$
Input #2
10 998244353
Output #2
53999264
Input #3
200 998244353
Output #3
112633322
题目信息
题号
agc036_f
时间限制
4 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。