跳到正文

个人记录

P1595题解 信封问题 错排

yqzx0307约 1 分钟
原文
文章信息与版本

文章信息

发布
2026年2月5日
收录
2026年6月15日
更新
2026年11月14日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include <bits/stdc++.h>
using namespace std;
#define int long long
constexpr int maxn=2e1+10;
int a[maxn];

signed main()
{
    int n;
    scanf("%lld",&n);
    a[2]=1;
    for (int i=3;i<=n;++i)
    {
        a[i]=(i-1)*(a[i-1]+a[i-2]);
    }
    printf("%lld",a[n]);
    return 0;
}
https://www.luogu.com.cn/problem/P1595
原文