We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Dude, you are using same m in your code... which will keep on becoming zero after completion from while loop and it will never be equal to j, better try out with this:
include
include
using namespace std;
int main() {
long int i=0,j=0,k=0,m=0,x=0,d=0,r=0,m1=0;
cin>>i>>j>>k;
for(m=i;m<=j;m++)
{
r=0;
m1=m;
while(m1!=0)
{
d=m1%10;
r=r*10+d;
m1=m1/10;
}
if((abs(r-m)%k)==0)
x++;
}
cout<<x;
return 0;
}
I hope you got what's wrong.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Beautiful Days at the Movies
You are viewing a single comment's thread. Return to all comments →
Dude, you are using same m in your code... which will keep on becoming zero after completion from while loop and it will never be equal to j, better try out with this:
include
include
using namespace std; int main() {
} I hope you got what's wrong.