[SEERC 2020] Modulo Permutations

Luogu
IDLGP10744
Time1000ms
Memory256MB
DifficultyP5
2020ICPCSEERC
求长度为 $n$ 的 $1 \sim n$ 的所有排列总数,其中满足 $p_i \bmod p_{i+1} \leq 2$ 的(此处 $p_{n+1} = p_1$),对 $10^9 + 7$ 取模后的值。 ## Input 一个整数 $n\ (1 \leq n \leq 10^6)$。 ## Output 输出答案模 $10^9+7$ 后的值。 [samples]
Samples
Input #1
1
Output #1
1
Input #2
2
Output #2
2
Input #3
3
Output #3
6
Input #4
4
Output #4
16
Input #5
5
Output #5
40
Input #6
1000000
Output #6
581177467
API Response (JSON)
{
  "problem": {
    "name": "[SEERC 2020] Modulo Permutations",
    "description": {
      "content": "求长度为 $n$ 的 $1 \\sim n$ 的所有排列总数,其中满足 $p_i \\bmod p_{i+1} \\leq 2$ 的(此处 $p_{n+1} = p_1$),对 $10^9 + 7$ 取模后的值。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": {
      "LuoguStyle": "P5"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP10744"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "求长度为 $n$ 的 $1 \\sim n$ 的所有排列总数,其中满足 $p_i \\bmod p_{i+1} \\leq 2$ 的(此处 $p_{n+1} = p_1$),对 $10^9 + 7$ 取模后的值。\n\n## Input\n\n一个整数 $n\\ (1 \\leq n \\leq 10^6)$。\n\n## Output\n\n输出答案模 $10^9+7$ 后的值。\n\n[samples]...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments