# BOOKPACK - Editorial

Author & Editorialist: Nishank Suresh
Testers: Takuki Kurokawa, Utkarsh Gupta

775

None

# PROBLEM:

Chef has X shelves of books with Y books each. One box can hold Z books, and books from different shelves must go into different boxes.
What’s the minimum number of boxes needed to hold all the books?

# EXPLANATION:

Let’s find the number of boxes to hold all the books of a single shelf. We can then multiply this by X to get the final answer.

We want to fit Y books into boxes of size Z. If we had K boxes, we could fit K\cdot Z books.

So, we want the smallest integer K such that K\cdot Z \geq Y.
This tells us that K = \left\lceil \frac{Y}{Z} \right\rceil, where \left\lceil \ \ \right\rceil denotes the ceiling function.

So, the answer is simply

X\times \left\lceil \frac{Y}{Z} \right\rceil

# TIME COMPLEXITY

\mathcal{O}(1) per test case.

# CODE:

Code (C++)
#include "bits/stdc++.h"
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
using ll = long long int;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

int main()
{
ios::sync_with_stdio(false); cin.tie(0);

int t; cin >> t;
while (t--) {
int x, y, z; cin >> x >> y >> z;
cout << x * ((y + z - 1)/z) << '\n';
}
}