hi.答题卡

答题卡

题目描述

牛牛即将要参加考试,他学会了填答题卡。

可惜他竖着的答题卡填成了横着的 : (

好奇的他想知道对于 n 道题,每道题 n 个选项的答题卡 ( n * n 的矩阵 ),满足横答题卡和竖答题卡图形一致的方案数有多少种。

注:每道题只能选择一个选项,即 n * n 的矩阵中只能涂黑 n 个空。求横竖对称的方案数。

输入描述

第一行给出 n。

输出描述

输出方案数,答案对 1 0 9 + 7 10^9+7 109+7 取模

示例1

输入
3
输出
4
说明

在这里插入图片描述

备注

对于 50    % 50\;\% 50% 的数据有 n ≤ 10 n \leq 10 n10

对于 100    % 100\;\% 100% 的数据有 n ≤ 1 0 5 n\le 10^5 n105

Code

// #include <iostream>
// #include <algorithm>
// #include <cstring>
// #include <stack>//栈
// #include <deque>//堆/优先队列
// #include <queue>//队列
// #include <map>//映射
// #include <unordered_map>//哈希表
// #include <vector>//容器,存数组的数,表数组的长度
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
typedef long long ll;
const ll mod=1e9+7;
const ll N=1e5+10;
ll a[N];

void solve()
{
    ll n;
    cin>>n;

    a[1]=1,a[2]=2;
    for(ll i=3;i<=n;i++) a[i]=(a[i-1]+(i-1)*a[i-2])%mod;
    cout<<a[n]<<endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);

    ll t=1;
    //cin>>t;
    while(t--) solve();
    
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Pretty Boy Fox

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值