List of all available Websheets
Viewing cpp/division-modulo/sections by redekopp@usc.edu. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
Property | Value |
---|---|
Description html markup shown to student | A department caps their class size at 65. Given a number of students wanting to take a course, calculate how many sections will be needed. <p> One way to round up is to take advantage of integer division. If dividing by k and you want to round up to the nearest integer, simply add (k-1) before dividing. <p> $\large \frac{(n + (k-1))}{k}$ <p> So for example if we want to divide <tt>n/10</tt> and round up, we can add 9. <p> $\frac{(n+9)}{10}$ <p> In this way, if n is 10 then we know 10/10 = 1. Because of integer division we will get the same answer by adding 9 first (i.e. 19/10=1).<br> If n is between 11-19, which would cause us to round up when dividing by 10 then adding 9 will also achieve the same: <pre> (11+9)/10 = 2 ... (19+9)/10 = 2 </pre> |
Public permissions | |
Remarks Comments, history, license, etc. | Copied from problem cpp/division-modulo/kilograms (author: redekopp@usc.edu) Copied from problem cpp/division-modulo/building-floor (author: redekopp@usc.edu) Copied from problem cpp/cin/building_floor (author: redekopp@usc.edu) Copied from problem cpp/cin/average (author: redekopp@usc.edu) Copied from problem cpp/var-expr/in_n_days (author: redekopp@usc.edu) Copied from problem cpp/var-expr/char_arith (author: redekopp@usc.edu) Copied from problem cpp/var-expr/hello (author: daveagp@gmail.com) |
Engine | |
Template / Reference solution |
using namespace std; int main() { // variable for the number of students \[ int students; ]\ cout << "Number of students: " << endl; \[ cin >> students; ]\ cout << "Sections needed = " << \[ (students + 64) / 65 ]\; return 0; } |
C++ test suite json list of stdin/args tests e.g. [{"stdin":"hi", "args":["4", "5"]}, {"stdin":"noargs"}] to just run once with no input use [{}] | [ {"stdin":"130", "args":[]}, {"stdin":"131", "args":[]}, {"stdin":"1", "args":[]}, {"stdin":"0", "args":[]} ] |
Solution visibility |
Note: problems are open-source by default (see 'Public permissions'). Assumed license for open problems is Creative Commons 4.0 Attribution-ShareAlike unless specified in 'Remarks'.