what is the diff. between these two
one WA and one AC
https://www.codechef.com/viewsolution/40929105
https://www.codechef.com/viewsolution/40943572
return type of floor is float
3 Likes
floor() return type is double where a/b in CPP gives Integer result.
floor(6/2)=3.0
6/2=3
So that is why there is a problem.
2 Likes
u sure floor gives float ?
JIC YDK we can see your edits
not understand @urvashi plz make clear
that the thing i want to ask why two diff result for same code
because your floor(k/n) return float value, which is not acceptable by judge. You could have wrote (long long) floor(k/n) or simply k/n to get desired result.
1 Like
C++ floor() - C++ Standard Library.
if you don’t believe me then see this article or else CPP Docs
1 Like
Specifically, compare the output from the two solutions for the Test Input:
1
1 1000000
2 Likes
ohhhh now i got
thnku
1 Like
this worked int x=floor(k/n);
cout<<x<<endl;