Calculus Very Weak Test Cases ☹️

#include <iostream>
using namespace std;

int main() {
	int n;
	cin>>n;
	if(n==2)cout<<"665496238";
	if(n==3)cout<<"865145109";
	if(n==1000000)cout<<"568817989";
	if(n==999999)cout<<"989271733";
	return 0;
}

WTH , how this solution is AC @admin

9 Likes

lol :joy: :joy:

https://www.codechef.com/viewsolution/40366968
https://www.codechef.com/viewsolution/40431128
https://www.codechef.com/viewsolution/40434234
https://www.codechef.com/viewsolution/40424649
https://www.codechef.com/viewsolution/40432825
https://www.codechef.com/viewsolution/40424664
https://www.codechef.com/viewsolution/40424649
https://www.codechef.com/viewsolution/40424454

LOL :joy:

Why shouldn’t be it AC. Almost everyone has same solution. It was just that there was only four test cases. And the last two were very easy to find out.
Just put assert and find out the value of N

1 Like

One can binary search the testcases

7 Likes

binary search on testcases https://youtu.be/VdqR6L6mRac?t=3292

Very Disappointing!

How please mention??

I used matlab to get some answers and then used them to predict the expression simply came out as 2*(1/1 + 1/3 + 1/5 …) . Took much time to figure out. But indeed the above scenario happened due to much less test cases.

2 Likes

Actually this is quite ingenius

I manipulated it into this expression Wolfram and then changed values of n to guess it.Frankly I dont see how a person without the knowledge of Parseval’s Theorm could have solved it

Check Errichto’s video- https://youtu.be/VdqR6L6mRac

It is basically a hit and trial type. Suppose we know in Calculus problem, N<=10^6.
Put a assert- assert(N>=999990 and N<=1000000);
and print anything. Any number outside this range, should give a Runtime Error. Like this, increase the bound.
assert(N>=999995 and N<=1000000);
Like this, going on, we find that N=999999 and N=1000000

2 Likes

I think we can solve it by Cauchy’s Residue Theorem as well. Wan’t able to prove that the integral of the semi-circle arcs is zero. Figured out it must be zero based on the example values given. The residue of the poles is equal to our integral.

What would you say for a guy from my college who did not use any assert in his code but still got
AC by cracking those cases . I mean did he got dreams of those test cases :frowning:

There is a thing called as “friends/telegram/youtube” :wink:

:pensive:

Do you mean you solved the problem completely or you just guessed those testcases?

If it’s guessing, you should have tried your luck at some lottery. :slight_smile:

1 Like

no not me , I used online calculator of Wolfram alpha

There should be System Testing in Codechef also.

2 Likes