this solution for PROSUM gave a wrong answer… i dont understand why, while the same solution with the data type changed
long long int got accepted. Why did the first solution not get accepted?
#include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{ unsigned long int ans,n,i,count=0,c=0;
scanf("%lu",&n);
unsigned long int a;
for(i=0; i<n; i++)
{ scanf("%lu",&a);
if(a!=1 && a!=0) {count++;}
if(a==2) {c++;}
}
ans=((count*(count-1))/2)-((c*(c-1))/2);
printf("%lu\n",ans);
}
return 0;
}
this below code got accepted
#include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{ long long int ans,n,i,count=0,c=0;
scanf("%lld",&n);
long long int a;
for(i=0; i<n; i++)
{ scanf("%lld",&a);
if(a!=1 && a!=0) {count++;}
if(a==2) {c++;}
}
ans=((count*(count-1))/2)-((c*(c-1))/2);
printf("%lld\n",ans);
}
return 0;
}