No.1529 Constant Lcm
タグ : / 解いたユーザー数 167
作問者 :
PCTprobability
/ テスター :
tatyam
👑
Kazun
Note
The time limit for this problem is $3$ sec.
Problem Statement
Find $\mathrm{lcm}(1\times (N-1),2 \times (N-2),3 \times (N-3),\dots, (N-2) \times 2, (N-1) \times 1) \bmod 998244353$.
Formally, define a sequence of positive integers $A=(A_1,A_2,...,A_{N-1})$ by $A_i=i \times (N-i)$.
Output the smallest positive integer divisible by all $N-1$ elements of $A$, modulo $998244353$.
Input
$N$
- All inputs are integers.
- $2 \le N \le 10^6$
Output
Output $\mathrm{lcm}(1\times (N-1),2 \times (N-2),3 \times (N-3),\dots,(N-2) \times 2,(N-1) \times 1) \bmod 998244353$.
Sample
Sample 1
Input
7
Output
60
Since $\mathrm{lcm}(1\times 6,2\times 5,3\times 4,4\times 3,5\times 2,6\times 1)=\mathrm{lcm}(6,10,12,12,10,6)=60$, the answer is $60$.
Sample 2
Input
2021
Output
684169707
Output the remainder when divided by $998244353$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。