# A simple doubt

hey,guys
i was solving this question but i had doubt,
int ans1=0,ans2=0;
ans1 += ceil((x0.1)/(20.1));
ans2 += (x+1)/2;

why ans1 and ans2 gives different ans?
if x is odd
ans1 = odd/2 = 3/2 = 2
ans2 = odd+1/2 = 3+1/2=2
If even
ans1 = even/2 = 4/2 =2
ans2 = even+1/2 = 4+1/2=2
i submitted using both one got AC and one WA

ceil returns a double, so for large numbers the output is in exponential form.

First of all, ceil() function rounds the current floating point number to the next integer (but it returns it as a double). So if your number is 0.5, ceil(0.5) will be 1 .
Coming to your solution (the one that got WA), lets have a look at your code snippet:

``````for(auto i : mp){
ans += ceil((i.second*0.1)/(2*0.1));
// cout<<i.first<<" "<<i.second<<endl;
}
``````

you donâ€™t need to multiply by 0.1 there, you just need to do this:

``````for(auto i : mp){
ans += ceil((i.second)/2.0);
}
``````

The compiler will convert to float and find the ceiling of the answer automatically.

Check my code: My Solution