Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

why did this PROSUM solution not get accepted?

$
0
0

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; }


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>