spoj-wrong aswer in problem TIPTOP

Please tell me why my code is showing wrong answer.The link to my code is http://ideone.com/8EtFsh .

i think it is the data type which is creating the problem for you, try to use the unsigned long long for n and try.

@buffy20:Your logic is 100% correct but the problem is sqrt function gives output in integer type you have to typecast…Here is my code that got AC…Hope it helps…:slight_smile:

I have already tried using unsigned long long but it is still giving wrong answer

Are you using the compiler C++ 4.3.2 ??. Your code works perfectly with this compiler.Some thing in C compiler that i am not aware of , sorry :frowning:

I am using gcc 4.9.2

please tell me which data types you changed because my code showing WA with C++4.3.2 even after changing to unsigned

But my modified code is also giving WA. Please point out error in it. The link to my modified code is http://ideone.com/JeBAYn

language i have selected is C++(g++4.3.2) . I have pasted the code in the source code area rather than uploading it and it is passing. and i have not changed anything in your code.

I have capture the screen shot with the AC and your solution http://tinypic.com/r/250rn1w/8

yeah its accepted in C++(g++4.3.2) but can u tell me why it is not getting accepted in C gcc 4.9.2??

by the way;thanks for the help.

I am not sure , i my primary language in C# and sometime i code in c++ , so not kind of expert to give the answer. Just check the data type limit in the C gcc 4.9.2