Here’s the C code for the problem “Ciel and A - B”. Though it works awesome for sample input and a few other corner cases I tried, it doesn’t work and gives me a “wrong Answer” error.
Can anyone please help me with this:
#include <stdio.h>
#include <math.h>
int main(void) {
int A, B;
scanf ("%d %d", &A, &B);
int num = A - B;
if ( (int) log10 (num) + 1 == (int) log10(num - 1) + 1 && (num - 1) % 10 != 0)
{
printf ("%d\n", num - 1);
return 0;
}
else
{
printf ("%d\n", num + 1);
return 0;
}
}