Job distrbution
Oct 15, 2016 at 12:59pm UTC
I'm trying to solve two printers problem (
http://www.codeabbey.com/index/task_view/two-printers) and I think i get the formula for the calculation but I still get problems finding the right answer, I don't know which of the four is the right one.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#include <iostream>
#include <cmath>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;
using std::ceil;
using std::floor;
using std::setprecision;
int main()
{
long double x;
long double y;
long double n;
double long a;
double long b;
double long a1;
double long b1;
cout << "Enter x, y, and n :" << endl;
cin >> x >> y >> n;
a = ( ceil ((y*n) / (x+y)) );
b = ( floor ((x*n) / (x+y)));
long double ta = a*x ;
long double tb = b*y;
a1 = ( floor ((y*n) / (x+y)) );
b1 = ( ceil ((x*n) / (x+y)));
long double ta1 = a1*x;
long double tb1 = b1*y;
cout << setprecision (9) << ta << endl;
cout << tb << endl;
cout << ta1 << endl;
cout << tb1 << endl;
Never mind I figured it out.
Last edited on Oct 15, 2016 at 4:44pm UTC
Oct 15, 2016 at 6:00pm UTC
You can change the icon of the forum to a checkmark to show it is finished :)
Topic archived. No new replies allowed.