{"problem":{"name":"[HUSTFC 2023] 新取模运算","description":{"content":"在这道题中，我们定义一个新的运算符号 $\\oplus$ 并将其称为新取模运算。 当计算 $x \\oplus y$ 时，如果 $x$ 不是 $y$ 的倍数，则得到 $x$ 除以 $y$ 的余数; 否则令 $x$ 不断除以 $y$ 直到 $x$ 不再是 $y$ 的倍数，假设它为 $x'$，然后得到 $x'$ 除以 $y$ 的余数。例如，$4\\oplus 5=4$，$20\\oplus 5=4$，$10","description_type":"Markdown"},"platform":"Luogu","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":{"LuoguStyle":"P4"},"is_remote":true,"is_sync":true,"sync_url":null,"sign":"LGP9774"},"statements":[{"statement_type":"Markdown","content":"在这道题中，我们定义一个新的运算符号 $\\oplus$ 并将其称为新取模运算。\n\n当计算 $x \\oplus y$ 时，如果 $x$ 不是 $y$ 的倍数，则得到 $x$ 除以 $y$ 的余数; 否则令 $x$ 不断除以 $y$ 直到 $x$ 不再是 $y$ 的倍数，假设它为 $x'$，然后得到 $x'$ 除以 $y$ 的余数。例如，$4\\oplus 5=4$，$20\\oplus 5=4$，$100\\oplus 5=4$。\n\n给定一个质数 $p$，接下来会有多组询问，对于每次询问会给出一个整数 $n$，你需要计算出 $n!\\oplus p$ 的值。其中 $n!$ 是 $n$ 的阶乘，即所有小于等于 $n$ 的正整数的乘积。\n\n## Input\n\n第一行包含两个整数 $T\\ (1\\le T\\le 10^5)$ 和 $p\\ (2\\le p\\le 10^6)$，分别表示询问的次数和给定的质数。\n\n接下来 $T$ 行，每行包含一个整数 $n\\ (1\\le n\\le 10^{18})$，含义如题目所述。\n\n## Output\n\n对于每次询问，输出一行包含一个整数，即 $n!\\oplus p$ 的值。\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"LGP9774","tags":["2023","O2优化","高校校赛"],"sample_group":[["3 7\n11\n45\n14","4\n1\n2\n"],["2 10007\n1919\n810","3152\n3679\n"]],"created_at":"2026-03-03 11:09:25"}}