Same solution on editorial of CSUB... still results Time Limit Exceeded

Same solution on editorial of CSUB… still results Time Limit Exceeded.
Editorial link: http://discuss.codechef.com/questions/47237/csub-editorial
Code is here: http://www.codechef.com/viewplaintext/4298438
#include<stdio.h>
main()
{
long long int result;
long int i,t,n,count;
char s;
scanf("%ld",&t);
while(t–)
{
count=0;
scanf("%ld",&n);
s = (char
)malloc(sizeof(char)(n+1));
fflush(stdin);
gets(s);
for(i=0;i<n;i++)
if(s[i]==‘1’)
count++;
result = (count
(count-1))/2 + count;
printf("%lld\n",result);
}
return 0;
}

I think may be usage of gets() is resulting to TLE.It’s better if you use scanf(). Here is your accepted solution.
http://www.codechef.com/viewplaintext/4365088

always use scanf() and printf() in codechef competitions as even cin and cout can give tle … happened to me in the july long dishown .