Cod sursa(job #1872854)

Utilizator GrandmasterSoucup Bogdan Grandmaster Data 8 februarie 2017 17:15:53
Problema 12-Perm Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <fstream>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <cstring>
//#include <unordered_map>
#include <iomanip>
#include <time.h>
#include <stdio.h>
#include <bitset>
#include <map>
#define MAX 500000000000
//#include <iostream>
//#include <windows.h>
#include <deque>
using namespace std;
//ifstream cin("jocul.in");
//ofstream cout("jocul.out");
ifstream cin("12perm.in");
ofstream cout("12perm.out");
//#define ghita 1004
int x[15000004];
int main()
{
    int n, mex = 1048576;
    cin >> n;
    x[1] = 1;
    x[2] = 2;
    x[3] = 6;
    for(int i = 4; i <= n; i++)
        x[i] = (x[i - 1] + ((x[i - 2] * (i - 1)) % mex) % mex);
    cout << x[n];
    return 0;
}