Cod sursa(job #175676)

Utilizator Mishu91Andrei Misarca Mishu91 Data 10 aprilie 2008 11:59:44
Problema 12-Perm Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <cstdio>
#define MOD 1048576

long n;

int T1, T2, T3, T4;

int main()
{
  freopen("12perm.in","r",stdin);
  freopen("12perm.out","w",stdout);
  scanf("%ld\n",&n);
  
  T1 = 1;
  T2 = 2;
  T3 = 6;
  T4 = 12;
  
  for(int i=5; i<=n; i++)
  {
    T4 = (T3 + T1 + 2 * (i - 2) ) % MOD; 
    T3 = T4;
    T2 = T3;
    T1 = T2;
    
  }
    
  printf("%d\n",T4);
  return 0;
}