Computer Science Canada Programming Contest! |
Author: | Flikerator [ Wed Mar 02, 2005 5:20 pm ] |
Post subject: | Programming Contest! |
Okay there is a programming contest on Tuesday that we are competing in. We are the Junoir team and its meant for Seniors so we are kinda outmatched. We have a sample question and I was wondering if what I answered is correct, here is the strangly worded question; Quote: Stan build a robot car that can drive along a straight runway and that can modify its speed ever second: It can gowever change its speed up or down by one meter per second: It it is going 5 meters per second during the space of one second, it can slow down to 4 meters per second, stay at meters per second, or speed up to 6 meters per second in the next time span. Stan can control its top speed as well as the total distance the car must travel. Speed here is taken to mean average speed. To say, for example, that the speed at a given time is 7 meters per second, means, that during the given time span of one second, the car travels exactly 7 meters. Stan's car will always trabel as fast as possibl, given that it must start from standstill and can't crash through the finish line: The finish line might possibly be a blank wall. During the first second the car's speed is therfor one meter per second and during the last second, its speed must also be one meter per second. If for example the car has been given the instruction to go 100 meters at a top speed of 8 meters per second, its best time will be 20 seconds, although the details where it sped up or slowed down might vary. One solution is show here: DATA42 )DATA42 on the second try, will contain 10 lines each containing one integor. (Valuebetween 1 and 32000 inclusive). They represent the 5 sets of 2 data: First, the distance to be traveled and second, the speed limit of the robot car. Write a program that will calculate the fastest time it will take to finish the race in each of the 5 instances. Output should mirror the output of the sample. Sample Input: 100 8 1 10 43 1 1000 1000 32000 100 Sample Output: Stan's car travels the 100 meters in 20 seconds. Stan's car travels the 1 meter in 1 seconds. Stan's car travels the 43 meters in 43 seconds. Stan's car travels the 1000 meters in 63 seconds. Stan's car travels the 32000 meters in 419 seconds. Typing it out I fully understand it now and know that my code is wrong. I know how to do it, just not how to do the Math of it (Grade 10 begining) so if you can help I would love it. If I find a solution or close to it I will post. EDIT NOTES You won't know what the values are, those are examples. You have to open up a file on the disc and use them (So unknown). Last speed before the "collision" HAS to be 1. It must speed up and know when to start losing speed so it can be 1 without the user doing anything... More to come |
Author: | ssr [ Thu Mar 03, 2005 6:34 pm ] |
Post subject: | |
lol i did that question robocar eh? ok there is a trick in this lololol try to find it HINT: time = distance / speed and waht does not change in this question what does chsange eh? o kits not that hard after u understand teh question try it. 8) 8) BTW, if u want, I will give u teh code for it tmr... |
Author: | ssr [ Thu Mar 03, 2005 6:35 pm ] |
Post subject: | |
Quote: Typing it out I fully understand it now and know that my code is wrong. I know how to do it, just not how to do the Math of it (Grade 10 begining) so if you can help I would love it.
no, u can surely solve it using grade 10 math u just havent fully undertand the question yet... 8) |
Author: | Flikerator [ Thu Mar 03, 2005 7:12 pm ] | ||
Post subject: | |||
I know I figured it out after I wrote it, here is a sloution to it;
As you can see, time = distance / speed DOES NOT work because you can go up and down speeds, and must not exceed a certain speed (top speed) and end at one. ![]() |
Author: | ssr [ Thu Mar 03, 2005 10:59 pm ] |
Post subject: | |
nono I meant ok her eis an example highest speed is 7 now, speed 1,2,3,4,5,5,5,5,4,3,2,1 total of 40 12 sec or 1,2,3,4,5,6,5,4,4,3,2,1 total of 40 12 sec although at different speed if u try to get as fast as possible but under teh highest speed u will get the same sec and thats what u need My team did a loop adn solved the problem I will post my solution tmr or monday, since its in school ![]() |