Cod sursa(job #1394181)

Utilizator pepsiM4A1Ozturk Arif pepsiM4A1 Data 20 martie 2015 09:02:44
Problema 12-Perm Scor 95
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <cstdio>
#include <algorithm>
using namespace std;
int n;
int t[15000001];
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);
            t[i]=t[i]&((1<<20)-1);
    }
    printf("%d\n",t[n]);
}