Cod sursa(job #1394197)

Utilizator pepsiM4A1Ozturk Arif pepsiM4A1 Data 20 martie 2015 09:16:49
Problema 12-Perm Scor 95
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 kb
#include <cstdio>
#include <algorithm>
using namespace std;
int n;
int t[15000001];
const int p=(1<<20)-1;
int main()
{
    freopen ("12perm.in","r",stdin);
    freopen ("12perm.out","w",stdout);
    t[1]=1;
    t[2]=2;
    t[3]=6;
    t[4]=12;
    scanf("%d",&n);
    for(int i=5;i<=n;i++)
    {
            t[i]=(t[i-1]+t[i-3]+2*(i-2))&p;
    }
    printf("%d\n",t[n]);
}