Help me in solving CIELAB problem

My issue

According to my testcases i get the correct answer but while submitting it is wrong

My code

#include <iostream>
using namespace std;

int main() {
	// your code goes here 
	int i,j,l,m,k,p;
	cin>>i;
	cin>>j; 
	k=i-j; 
	p=k%10; 
	if (p==0)
	{
	    k=k+1;
	}
	else if (p>=1 && p<=9)
	{
	    k=k-1;
	}
	cout<<k<<"\n";
	return 0;
}

Problem Link: CIELAB Problem - CodeChef

The problem is that you cannot have ZEROS in your alternate answer.
Eg:say that the value of p(k%10) is 1,now it subracts 1 to the value of k which becomes 0.
if(p<=1){
k++;
}
else{
k–;
}

1 Like