pub(crate) trait NumExt {
fn div_ceil(self, other: Self) -> Self;
fn div_floor(self, other: Self) -> Self;
}
impl NumExt for i32 {
fn div_ceil(self, other: Self) -> Self {
let d = self / other;
let r = self % other;
if (r > 0 && other > 0) || (r < 0 && other < 0) {
d + 1
} else {
d
}
}
fn div_floor(self, other: Self) -> Self {
let d = self / other;
let r = self % other;
if (r > 0 && other < 0) || (r < 0 && other > 0) {
d - 1
} else {
d
}
}
}