Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApplication70
- {
- class Program
- {
- static void Main(string[] args)
- {
- int temp1 = 5001, temp2 = 1000000007;
- Int64[,] mass = new Int64[temp1, temp1];
- for (int i = 0; i < temp1; i++)
- {
- mass[i, 0] = 0;
- mass[i, i] = 1;
- }
- for (int i = 0; i < temp1; i++)
- {
- for(int j = 1; j <= i - 1; j++)
- mass[i, j] = ((mass[i - 1, j - 1]) % temp2 + j * mass[i - 1, j] % temp2) % temp2;
- }
- int n = int.Parse(Console.ReadLine());
- Int64 sum = 0;
- for(int i = 0; i <= n; i++)
- sum = (sum + mass[n, i]) % temp2;
- sum++;
- Console.WriteLine(sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement