sftm feb15

What is wrong in this…
include <stdio.h>
include <stdlib.h>
include <math.h>
define size6 10000003
define size5 100001
define s(n) n=Scan_f()
define loop(i,N) for(i=0;i<N;i++)
define pll(n) printf("%lld\n",n)
typedef long long int ulli;
inline unsigned long long int Scan_f() { int c; do c = fgetc(stdin); while ( (c < ‘0’ || c > ‘9’) && c != EOF );
unsigned long long int a = 0;
while ( c >= ‘0’ && c <= ‘9’ )
{
a = a10 + (c - ‘0’);
c = fgetc(stdin);
}
return a;
}
ulli i,N,K,memofact[size6]={0},memofinal[size6]= {0};
ulli fact(ulli n) {
if(n==1) return 1;
{ ulli x;
if(memofact[n]!=0) return memofact[n];
{ x=(n(fact(n-1)))%K;
memofact[n]=x;
return x;
}
}
}
ulli modulo(ulli n)
{ ulli y;
if(n%2==0) { y=n/2;
y%=K;
y=((n+1)K); y=K;
y
=((n)K); y=K;
}
else
{
{
y=(n+1)/2;
y%=K;
y*=((n)K); y=K;
y*=((n)K); y=K;
}
}
return y;
}
ulli tag=10000;
ulli calc(ulli n) { if(n==1) return 2%K; { ulli x; if(memofinal[n]!=0) return memofinal[n]; { while(n>tag) { x=fact(tag); tag+=1000; } ulli y; x=(fact(n+1)-1)%K; y=modulo(n);
x=(x+y)%K;

``````    memofinal[n]=x;
return x;
}
``````

}
}
int main() { memofact[1]=1;
s(N);
s(K); // memofinal[0] fOR STOREING NO.
{ ulli ans=0;
{ loop(i,N) { s(memofinal[0]); if(memofinal[0]>=(K-1)) ans=(ans+modulo(memofinal[0]))%K; else ans=(ans+calc(memofinal[0]))%K; } pll(ans); } } return 0; }