I want to find the lowest hop count from source to destination. The challenge, in summary:
The first line contains the number of test cases T, 1 ≤ T ≤ 100000.
The next T lines each contains three integers A, B, and M. 1 ≤ A ≤ B ≤ 1012. 1 ≤ M ≤ 1012.For each test case, print the number of multiples of M that are in the range [A, B] (inclusive).
My output is correct but the execution time of my program is like 1.0015 seconds when given 100000 entries. But I need to do the program within 1 second time frame. I have tried a lot to reduce the execution time but couldn't. Can anybody help me to achieve an execution time within 1 sec.
#include<stdio.h>
int main()
{
unsigned int n, i, j, k, h,count=0,l=0;
scanf("%u", &n);
for (i=0;i<n;i++)
{
scanf("%u %u %u", &j, &k, &h);
l=j;
count = 0;
while(l<=k)
{
if(l%h==0)
{
count=count+1;
}
l++;
}
printf("%u\n", count);
}
return 0;
}
sample input-> 1 10 2
sample output-> 5