P11075 题解

· · 题解

题目传送门

思路

每一个排列方式 p 仅有唯一对应的字符串 s,故答案为 \prod\limits_{i=1}^{n+1}i,即 (n+1)!

AC CODE

#include<bits/stdc++.h>
using namespace std;
int read(){int x=0;char f=1,ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();return x*f;}

int main(){
    int n=read();
    long long ans=1;
    for(int i=1;i<=n+1;++i)
        ans=ans*i%998244353;
    cout<<ans;
    return 0;
}