1578.Less taolu

Time Limit: 1s Memory Limit: 256MB

Less taolu, more sincerity.
This problem is very easy to solve.
You may be very tired during this contest. So we prepared a gift for you.
You just copy and paste this code and you will get AC!
Ctrl + C && Ctrl + V is a necessary skill for a programming ape.

#include<iostream>
using namespace std;
const long long mod = 1e9+7;
long long func(int x){
    if (x==1||x==0){
        return 1;
    }
    return (x*func(x-1)+(x-1)*func(x-2))%mod;
}
int n;
int main(){
    cin>>n;
    cout<<func(n);
    return 0;
}

Input Format(From the terminal/stdin)

Input only a single integer $n$.

Output Format(To the terminal/stdout)

Please output the answer by this code.

Sample Input 1

Copy
3
 \n

Sample Output 1

Copy
11
  \n

Sample Input 2

Copy
100
   \n

Sample Output 2

Copy
372497045
         \n

Hints

$0≤N≤1e^5$.

Source: 2018 HNU新生赛

Submit

请先 登录

© 2025 FAQs