https://www.hackerrank.com/challenges/beautiful-days-at-the-movies/problem
#include<stdio.h>
int main()
{
int i,j,k,n,r,rev,count=0;
scanf("%d%d%d",&i,&j,&k);
for(;i<=j;i++)
{
n=i;
rev=0;
while(n > 0)
{
r=n%10;
rev=(rev*10)+r;
n=n/10;
}
if(abs(i-rev)%k==0)
count=count+1;
}
printf("%d",count);
return 0;
}
No comments:
Post a Comment