07-12-2010, 10:07 AM
|
#2
|
Addict
Posts: 241
Karma: 2617
Join Date: Mar 2009
Location: Greenwood, SC
Device: Kindle 2
|
Quote:
Originally Posted by pdurrant
The gods have heard rumours* that Achilles might not be as fast at running as they thought, so they decide to set him a task.
He must run a race on a special 100m racetrack. The special thing about this racetrack is that every time Achilles has run 10m along the race track, the whole track instantly stretches, as if made of rubber, by 100m.
Now Achilles can run indefinitely as a constant 10m/s. He really is a fast runner — good endurance too.
Have the gods set Achilles an impossible task? Can he ever finish the race?
|
Spoiler:
No, it's not impossible. Yes, he finishes the race 3 hours, 26 minutes, and 7 seconds after he starts.
At first I thought it was impossible, since for every 10m he ran, the track became 100m longer, thus he would be 90 meters further from the finish line every second. Then I re-read, and realized you said "the whole track stretches" which would mean it stretches with him on it. So after 1 second, he'd have run 10m, and then the track would stretch to 200m, and he would now be standing at the 20m mark (10% there). Another second, the track would stretch to 300m, and he'd now be at the 45m mark (15% there), after another second the track would be 400m, and he'd be at the 73 1/3m mark (18 1/3% there). Thus, he's slowly gaining.
Code:
/* achilles.c */
#include <stdio.h>
int main() {
long track = 100; // track length
double distance = 0; // position that Achilles is on the track.
const int stretch = 100; // stretch length
const int speed = 10; // Achilles speed in m/s
int seconds = 0;
while ((long)distance < track) {
seconds++;
distance += speed;
distance += (distance / track) * stretch;
track += stretch;
printf("Running Time: %dsec / Achilles' Position: %fm / Track Length: %ldm\n",seconds,distance,track);
}
return(0);
}
Last edited by clarknova; 07-12-2010 at 10:58 AM.
|
|
|