Cod sursa(job #1877243)

Utilizator sebiinfosimon sebastian sebiinfo Data 13 februarie 2017 10:00:27
Problema 12-Perm Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <cstdio>

using namespace std;

int main()
{
    freopen("perm12.in","r",stdin);
    freopen("perm12.out","w",stdout);
    int n,i;
    scanf("%d",&n);
    int a=8,b=8,c=4,s=12,x=4,y=2,mod=(1 << 20) - 1;
    for(i=5;i<=n;i++)
    {
        int cx=x&mod;
        x=b;
        s=(a+b+c)&mod;
        a=(a+b)&mod;
        b=(b+c)&mod;
        c=(cx+y)&mod;
    }
    printf("%d\n",s);
    return 0;
}