I am using gcc compiler, If I use math.h header file in my program & compile it like this
gcc filename.c , It says
" undefined reference to sqrt " So to link that library to my program m using
gcc filename.c -lm
So my question is How would I know that Codechef compiler is able to link the library or not as I am getting wrong answer for all the test cases in problem GCD Queries.
Just use #include<cmath>
It’ll work.
Judge will link that. If it does not, instead of WA, you will get Compilation error.Try to change your logic.
I tried different different test cases on my machine including what they gave…N before using math.h I tried same logic it fetched me 40 points + in subtask2 3 individual task were cleared…
If you are getting wrong answer, then there’s a mistake in your logic. It’s not the library problem. However, if the latter is the case, this may help you: http://stackoverflow.com/questions/11336477/gcc-will-not-properly-include-math-h
is a C++ library.
I think you should write your own function to calculate square of number, then use it instead of sqrt function in math.h library. If the WA is continue, you must check your logic, limits, MLE, overstacking, overflows, etc… Remember that number in C/C++ will be stored likely deque. If it overflowed, it won’t return error, it’ll return WA
I know that can only used in C++ ?