Edu Round 86 Problem C

I checked my wrong solution for problem C and it gave WA on the following test.

But when I run the test locally, it gives the expected output. Whys that?

Did you submit it again??
I checked it(locally) and it indeed gave the correct answer which matched with the jury’s answer.

It keeps failing on the same case. No idea why!!!

Can you try it on C++17.

seems like it worked

Got AC :slight_smile:

1 Like

So annoyed right now!!!

Which compiler are you using locally??

I use Sublime + MinGW.

C++ version ??

I use C++17 so I always submit my code in C++17 option.

I don’t specify the version, so whatever MinGW 8.1.0 uses, and I have no idea how to check.

This problem made me sad :frowning:

Still trying to figure why changing the C++ version matters so much. :confused:

@epsilon_573 Sir,Can you kindly share your approach for this problem?

Find the LCM of a and b, also if GCD(a,b) = min(a,b) answer is always 0. Number which satisfy the condition (i%a)%b == (i%b)%a , occur in [ i * LCM , i * LCM + max(a,b) ) . where i is any positive integer. Just count them and subtract them from R-L+1.

Surprisingly I am using C++14, this makes it more worrying.

@epsilon_573 Sir,how did derived these properties of a &b?

Just write a brute force solution and notice the pattern.

Watch this video of @striver_79 Codeforces Educational Round #86 | Yet Another Counting Problem | Watch till Code explanation - YouTube
He explained it very well.

1 Like