Pagini recente » Cod sursa (job #2719866) | Cod sursa (job #897244) | Cod sursa (job #110912) | Cod sursa (job #509846) | Cod sursa (job #423859)
Cod sursa(job #423859)
#include <stdio.h>
FILE *f=fopen("12perm.in","r"),*g=fopen("12perm.out","w");
int n,a[6],i;
int main(void)
{
fscanf(f,"%d",&n);
a[1]=1;
a[2]=2;
a[3]=6;
a[4]=12;
if (n<=4)
fprintf(g,"%d",a[n]);
else
{
for (i=5;i<=n;i++)
{
a[5]=a[4]+a[2]+2*(i-2);
a[5]=a[5]&(1<<20-1);
a[2]=a[3];
a[3]=a[4];
a[4]=a[5];
}
fprintf(g,"%d",a[4]);
}
fclose(g);
return 0;
}