Pagini recente » Cod sursa (job #1104611) | Cod sursa (job #1655852) | Cod sursa (job #1156541) | Cod sursa (job #1521748) | Cod sursa (job #13929)
Cod sursa(job #13929)
#include <stdio.h>
int N,R1,R2,R3,i,aux;
int main()
{
freopen("12perm.in","r",stdin);
freopen("12perm.out","w",stdout);
scanf("%d",&N);
R1=2; R2=6; R3=12;
for (i=5;i<=N;i++)
{
aux=R3;
R3=((R1 + R3 + 2*(i-2)) & 1048575);
R1=R2; R2=aux;
}
if (N==1)
printf("1");
else
if (N==2)
printf("2");
else
if (N==3)
printf("6");
else
if (N==4)
printf("12");
else
printf("%d",R3);
fclose(stdin);
fclose(stdout);
return 0;
}