My answer is correct but the question does not accept it.

Question : CIELAB.

import java.util.*;

public class Main

{

public static void main(String []args)

{

    Scanner sc=new Scanner(System.in);

    long a,b,x,d;

    a=sc.nextInt();
    b=sc.nextInt();
    x=a-b;
    d=x%10;
    x=x/10;
    d=(d+1)%10;
    x=x * 10+d;
    System.out.println(x);
}

}

Check out my solution to clear the implementation and algorithmic part-

https://www.codechef.com/viewsolution/14666183

EDIT- Still finding test case where your code fails.

Check the constraints, 1 <= B < A <= 10000. The first number is always greater than the second.

Okay, yes, you are correct. IDK why it emphasized “your answer must be positive number…” in output section then :confused:

Edited that part out. Thanks for pointing it out!! :slight_smile:

Check this test case :

10 1
Your output: 0 ; which is wrong as it is not a positive integer
1 Like

Your code fails int he following test case:

Input
10 1

Your Output
0

You have to print a positive number and leading zeroes are not allowed. Thus 0 is not a right answer.

The problem is that whenever the last digit of difference is 9 you are changing it to 0. But when the difference = 9, the answer becomes 0 which is not accepted.

1 Like

because 0 is not a positive number. It is the edge test case. @vijju123

Yes, I jsut figured that out. Although his algo and logic is nice as well.

1 Like

Nice spotting dear!! :slight_smile: