[GDKOI2024 提高组] 计算

Luogu
IDLGP10084
Time2000ms
Memory512MB
DifficultyP7
2024广东O2优化
定义 $F(x, a, b) = \gcd(x^a - 1, x^b - 1) + 1, x > 0$。 特别的,如果 $a = 0$ 或 $b = 0$,$F(x, a, b) = 0$。 现在给出五个非负整数 $m, a, b, c, d$。 令 $L = F(m, a, b) + 1$,$R = F(m, c, d)$。 问集合 $\{L, L + 1, L + 2, \dots, R - 2, R - 1, R\}$ 有多少个子集和是 $m$ 的倍数。 由于答案可能很大,你只需要输出方案数对 $998244353$ 取模后的结果就可以了。 **由于本题第三组数据有误,特别地,如果 $L > R$,输出 $1$ 即可。** ## Input 输入第一行为一个整数 $T$,表示数据组数。 接下来一行 $T$ 行,每行五个非负整数 $m, a, b, c, d$。 ## Output 对于每组数据,输出答案。 [samples] ## Note **【样例解释】** 经过计算可知 $L=1$,$R=5$,集合是 $1,2,3,4,5$,满足条件的子集和有以下 $8$ 个: $\{\}$,$\{5\}$,$\{2, 3\}$,$\{1, 4\}$,$\{1, 2, 3, 4\}$,$\{2, 3, 5\}$,$\{1, 4, 5\}$,$\{1, 2, 3, 4, 5\}$。 **【数据范围】** ::cute-table{tuack} | 测试点编号 | $m$ | $L,R$ | $a,b$ | $c,d$ | $T$ | 特殊性质 | | :----------: | :----------: | :----------: | :----------: | :----------: | :----------: | :----------: | | $1$ | $=2$ | $L=1,R=2$| $=0$ | $\leq 10$ | $\leq 5$ | 无 | | $2$ | $\leq 10$ |$L=1,R=m$ | ^ | ^ | ^ | ^ | | $3$ | $\leq 5$ | $\leq 10^3$ | $\le 10$ | ^ | ^ | $1$ | | $4\sim 6$ | $\leq 20$ | $\leq 2\times 10^3$ | ^ | ^ | ^ | 无 | | $7$ | ^ | $\leq 10^5$ | $\leq 10^2$ | $\leq 10^2$ | ^ | $2$ | | $8,9$ | $\leq 80$ | $\leq 10^9$ | ^ | ^ | ^ | 无 | | $10\sim 13$ | $\leq 2\times 10^3$ | $\leq 10^{18}$ | $\leq 10^3$ | $\leq 10^3$ | ^ | ^ | | $14\sim 17$ | $\leq 10^5$ | ^ | ^ | ^ | ^ | ^ | | $18\sim 20$ | $\leq 10^7$ | ^ | ^ | ^ | $\leq 10^4$ | ^ | - 特殊性质 1:$R - L + 1 \leq 20$; - 特殊性质 2:$R - L + 1 \leq 2000$; 对于全部数据,保证 $L < R$,$m > 0$。
Samples
Input #1
3
5 0 0 2 1
4 1 2 2 4
8 3 2 4 6
Output #1
8
1024
527847872
API Response (JSON)
{
  "problem": {
    "name": "[GDKOI2024 提高组] 计算",
    "description": {
      "content": "定义 $F(x, a, b) = \\gcd(x^a - 1, x^b - 1) + 1, x > 0$。 特别的,如果 $a = 0$ 或 $b = 0$,$F(x, a, b) = 0$。 现在给出五个非负整数 $m, a, b, c, d$。 令 $L = F(m, a, b) + 1$,$R = F(m, c, d)$。 问集合 $\\{L, L + 1, L + 2, \\dots, ",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P7"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP10084"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "定义 $F(x, a, b) = \\gcd(x^a - 1, x^b - 1) + 1, x > 0$。\n\n特别的,如果 $a = 0$ 或 $b = 0$,$F(x, a, b) = 0$。\n\n现在给出五个非负整数 $m, a, b, c, d$。\n\n令 $L = F(m, a, b) + 1$,$R = F(m, c, d)$。\n\n问集合 $\\{L, L + 1, L + 2, \\dots, ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments