@yashvardhan90 You are reading value of variable ‘g’ only once (for first test case), not for each testcase. Fixed it. Here is your AC code.
#include<stdio.h>
#include<math.h>
int main()
{ int t,g,i,n,q,h;
scanf("%d",&t);
while(t--)
{
scanf("%d", &g); // Changed Here
while(g--)
{
scanf("%d %d %d",&i,&n,&q);
if (i==q||n%2==0)
printf("%d\n",n/2);
else
printf("%d\n",(n+1)/2);
}
}
// getch();
return 0;
}
Hope it helps, Best Luck
1 Like