when you divide two ints, they get rounded down, so 3/2 is 1.5, rounded down to 1, then you perform ceilon 1, which is 1/
also you should use <cmath> instead of "math.h" as cmath is wrapped in namespace std, and math.h isn't, not that it matters much when you're using namespace std; at the top of your file but anyway