Cod sursa(job #917637)

Utilizator apopeid13Apopeid Alejandro apopeid13 Data 18 martie 2013 10:51:42
Problema 12-Perm Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.33 kb
#include <fstream>
#define md (1<<20)-1
using namespace std;
ifstream f("12perm.in");
ofstream g("12perm.out");
int n,t2,t3,t1,i,aux;
int t[]={1,2,6,12};
int main()
{
f>>n;
if(n<=4)
{
g<<t[n-1];
goto stop;
}
for(i=5;i<=n;i++)
{
aux=(t[3]+t[1]+2*(i-2))&md;
t[1]=t[2];
t[2]=t[3];
t[3]=aux;
}
g<<t[3];
stop:
return 0;
}