BIT Magazine (WA)

,

//i have tried the mathematical approach of finding the expectation of the remaining pages.But getting wrong ans in my sybmission.but i m getting right ans for the given test cases

#include<stdio.h>

#include<stdlib.h>

int main(){
int t,n,a,i=0,sum,p;

int* m;

scanf("%d",&t);

while(t-- > 0){

        scanf("%d",&n);

        scanf("%d",&a);

        m=(int*)malloc(sizeof(int)*a);

        sum=0;

        for(i=0;i<a;i++){

           scanf("%d",m+i);

           sum=sum+m[i];

           //printf("%d\n",m[i]);

        }

        sum=(n*(n+1))/2-sum;

        //printf("%d\n",sum);

        scanf("%d",&p);

        //i=n/2;


        float res=(float)((int)((sum*(float)(i-2*p)/i)*10000))/10000;

        printf("%.4f\n",res);



                  free(m);
}
      //getch();
      

        return 0;

}
link—>http://www.codechef.com/problems/TRMAG