1 / 6
Apr 2021

The problem is based on Julka7.
I have read all the top comments on the problem page and tried all/most of the test cases provided there and I can not find any wrong answers. But upon submission I keep getting WA for some reason.
Here’s the code on ideone.
raw code here:–

no code
  • created

    Apr '21
  • last reply

    Apr '21
  • 5

    replies

  • 668

    views

  • 2

    users

  • 1

    like

  • 2

    links

I can’t find any test case where your code gives the wrong answer, so I’ve no idea why you get WA.

I replaced

	char num1[103], num2[103];
	scanf("%s %s", num1, num2);

with

	char num1[203], num2[203];
	scanf("%s", num1);
	scanf("%s", num2);

and submitted as “C (clang 8.0)”, and got AC.

What’s the difference between clang 8.0 and gcc8.3?

I can’t explain why the buffers needed to be larger, unless the given ranges are incorrect, or there’s spaces somewhere.

As per your directions I did the same and got AC.
But I didn’t understand why increasing the buffer size makes any difference at all even though my initial buffer size was plenty for the required operation?:roll_eyes:
And for the difference between gcc and clang I found out that clang is newer and is generally more optimised and faster (superior to) than gcc.

I’ve checked, and the input is valid. There are no numbers greater the the given limits, no leading zeros, and no leading or trailing spaces.

So, I suspect something in your code!

edit: perhaps this:

		char difference[strlen(num1)];
		subtract(num1, num2, difference);

if num1 is ‘10’ and num2 is ‘0’, then difference will also be ‘10’ i.e. two characters. Where does the terminating null go?