Skip to content

Add floordiv and ceildiv for positives and negatives #113

Open
@LuchoBazz

Description

@LuchoBazz
// Reference: https://codeforces.com/contest/1782/submission/230743928
int floordiv(int a, int b) {
  return a > 0 ? a / b : -((-a + b - 1) / b);
}
 
int ceildiv(int a, int b) {
  return a > 0 ? (a + b - 1) / b : -(-a / b);
}
 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions