题解:P14313 [Aboi Round 2] IDSMILE

· · 题解

思路:

找规律发现,当 n \ge 2 时,结果为前 n-1奇数的乘积。

比如样例,当 n=4 时,结果为 1 \times 3 \times5 =15

所以,直接用模拟计算就行了。

记得取模!

:::info[Code]

#include<bits/stdc++.h>
using namespace std ;
const long long mod=998244353;
int main () {
    long long n,now=1,res=1; 
    cin>>n;
    for (int i=1;i<n;i++) {
        res=res*now%mod;
        now+=2;
    }
    cout<<res;
    return 0;
}

:::