Back to Problem Solutions forum
Im strugling to do task #22 i looked up some math theory on combined work and by my calculations i did everything corectly but the results are far from what i was expecting, here are the console results.
3
seconds for one page 1st
5
seconds for one page 2nd
4
all pages
12 how fast 1st print all
20 how fast 2nd print all
0.333333 this portion 1st print in 1 sec
0.2 this portion 2nd print in 1 sec
0.533333 this portion print together in 1 sec
7.5 how fast will print all together
Process returned 0 (0x0) execution time : 5.559 s
Press any key to continue.
my result is 7.5 instead of 9 and im not even sure how can you get to 9? also i red similar post and the tip given there. It said both printers does not work all the time together e.g. they cannot divide same page. But i still dont understand how am i supposed to implement that into my solution. pls, someone? im completely clueless, maybe someone has decent math theory article about this kind of problem? anything.
Your answer of 7.5 makes no sense at all. The slow printer takes 5 seconds to print a page. The fast printer takes 3 seconds to print a page. The answer can only be a whole number of seconds. If you print 1 of the 4 pages on the slow printer, it will take 5 seconds. While that is happening, printing the remaining 3 pages on the fast printer, will take 9 seconds. So, total time overall is 9 seconds, and it can't be done quicker.
Hi Andris!
Your calculations are a bit queer. If 1 page is printed in integer number of seconds on any of printers (3 or 5) then 4 pages could not be printed in non-integer amount of seconds :)
Imagine you want to print only 1 page. By your calculations 2 seconds should be enough, as 1st printer will do 0.66 and the 2nd will print 0.4 of the page. But we can't split the page between them, of course.
Let's regard this case in details:
So the best case is with 9 seconds, right?
If you feel that right now some problem is yet bit too hard for you, just skip it for now and get practice with others - you can always return to the skipped problem in a day or week, it often helps!
Okay i see now. But going page by page will take tramedeous time amount. I guess i have to divide them pages in some proportions for each printer in later test cases. but how do i know the proportions? I suppose i can look up proportion theory in math...daaaamn i wish i was paying more attention in math classes when i was younger :D
Anyway thank you, both of you.
See, your answer seems to be not far from correct. That means that your "proportions" are almost correct. Only need some fix to care of integer amount of pages.
completed! tho i cannot really explain the calculations behind my answers. :( for some reasons it all came down to how i round one of my calculations. if i round up "ceil"(in c++) i end up with some errors but when i use regular "round" those errors clear but then some others appear. so i figured i can calculate both results for all test cases and just print out the smallest. But i still dont really understand when was i supposed to round up and when not to... anyway im getting the correct results, took it almost 2 days, thank you so much for your help.
congrats!
so i figured i can calculate both results for all test cases and just print out the smallest
exactly what was supposed! at least I myself don't know any way other than checking few solutions "around" fractional :)