Pagini recente » Istoria paginii runda/savedemdecesunteminstare | Cod sursa (job #2120180) | Cod sursa (job #2428656) | Cod sursa (job #2022732) | Cod sursa (job #197147)
Cod sursa(job #197147)
#include <stdio.h>
#define MOD 1048576
int T[5] = {0,1,2,6,12};
int n,t1,t2,t3,x,y,rez,i;
int main(){
FILE *f = fopen("12perm.in","r");
fscanf(f,"%d",&n);
fclose(f);
if (n<=4) {
rez = T[n];
} else {
t1=12;
t2=6;
t3=2;
for (i=5;i<=n;i++) {
x = (t1+t3)%MOD;
y = (2*(i-2))%MOD;
x = (x+y)%MOD;
t1=t2;
t2=t3;
t3=x;
}
rez = x;
}
FILE *g = fopen("12perm.out","w");
fprintf(g,"%d",rez);
fclose(g);
return 0;
}