Nice Problem

Online C++ programming contests.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard, raimo

Nice Problem

Postby Blueteeth » Wed Aug 11, 2004 11:35 pm

Hey all , this is a simple and nice problem from a homework i had ( taken from ACM regional contests ) , you can consider it as a pseudo-Beginner's Task :)

The Amazing Mooville Jumping Skiers
input file: ski.in

The Mooville city officials have been trying to bring in business and entertainment to their small town. Recently, the ferry closed the canal that passes through the town. After witnessing a water ski show at Cypress Gardens, Mayor Moocky came up with an interesting twist that might just suit his small town. Every Saturday night on the closed canal, they will stage a ski jumping dual jump, using two connected ramps, where skiers will approach from opposite ends of the canal and jump over the ramp simultaneously. (The boats don't hit each other because they are kept perfectly straight on opposite sides of the canal.) The problem is, the boats they will use have different top speeds and accelerations, so they need to figure out what point on the canal to place the grandstands each week.

Given a length of canal with a boat at each end, and the acceleration and top speed of each boat, determine the meeting point. (You may assume each boat has constant acceleration until top speed is reached and they continue at top speed until after the amazing jump.)

Input:
Each input line contains five integer values separated by white space. The first integer will be the length of the canal in miles and will be between 1 and 20. The second integer will be the top speed of boat A and the third integer will be the acceleration of boat A. The fourth integer will be the top speed of boat B and the fifth integer will be the acceleration of boat B. The top speed of a boat will be in miles per hour and will be greater than zero. The acceleration of a boat will be given in miles per hour per second and will be greater than zero. The last line of the input file will have a canal length value of zero.

Output:
The first line of output should read "SKI OUTPUT". After that, for each line of input, there should be one line of output consisting of "JUMP POINT: " followed by the distance in miles to the collision point from the starting point of boat A. The distance must be rounded to two decimal places. The last line of output should read "END OF OUTPUT".

Sample Input
20 50 5 60 6
20 40 2 80 4
20 60 6 30 3
0 1 1 1 1

Output corresponding to the Sample Input
SKI OUTPUT
JUMP POINT: 9.09
JUMP POINT: 6.67
JUMP POINT: 13.33
END OF OUTPUT
User avatar
Blueteeth
 
Posts: 616
Joined: Thu Sep 25, 2003 9:54 pm
Location: Egypt

Re: Nice Problem

Postby RecursiveS » Thu Aug 12, 2004 2:01 pm

MatRiX_OvErLoadiNg wrote:Hey all , this is a simple and nice problem from a homework i had ( taken from ACM regional contests ) , you can consider it as a pseudo-Beginner's Task :)



In that case I'll move it to contests and sticky it for a while, as with previous beginners tasks... OK?
User avatar
RecursiveS
Site Admin
 
Posts: 1236
Joined: Thu Sep 18, 2003 8:33 am
Location: Dorset, UK

Postby Blueteeth » Fri Aug 13, 2004 9:37 am

Why i don`t see any codes ?! come on guys post something !.
User avatar
Blueteeth
 
Posts: 616
Joined: Thu Sep 25, 2003 9:54 pm
Location: Egypt

Postby Esran » Sat Aug 14, 2004 5:18 pm

The acceleration of the boats, what is it? Miles per minute squared or miles per second squared?
User avatar
Esran
 
Posts: 297
Joined: Fri Apr 09, 2004 4:42 pm

Postby Blueteeth » Sat Aug 14, 2004 5:25 pm

Neither , The acceleration is given by (miles/hour)/sec , which is compatible with the units of speed miles/hour , so you don`y have to do any conversions.
The acceleration of a boat will be given in miles per hour per second
User avatar
Blueteeth
 
Posts: 616
Joined: Thu Sep 25, 2003 9:54 pm
Location: Egypt

Postby scrappy » Sun Aug 15, 2004 5:00 pm

First time post.
Can it be assumed that both boats will reach top speed before intersecting?
scrappy
 
Posts: 3
Joined: Sat Aug 07, 2004 2:18 pm

Postby Kybo Ren » Sun Aug 15, 2004 6:15 pm

I'm not the one who posted the problem, but judging from the way it's worded, I'd say it's safe to assume that.
Kybo Ren
C++ Beginner
 
Posts: 2049
Joined: Wed Feb 11, 2004 9:28 pm

Postby Blueteeth » Sun Aug 15, 2004 8:58 pm

scrappy wrote:First time post.
Can it be assumed that both boats will reach top speed before intersecting?


Yes you can assume so ...
MatRiX_OvErLoadiNg wrote:(You may assume each boat has constant acceleration until top speed is reached and they continue at top speed until after the amazing jump.)


In fact if you didn't assume that , it will be as hard as hell ( for me at least ) :lol:
User avatar
Blueteeth
 
Posts: 616
Joined: Thu Sep 25, 2003 9:54 pm
Location: Egypt

Postby Kybo Ren » Sun Aug 15, 2004 9:39 pm

(You may assume each boat has constant acceleration until top speed is reached and they continue at top speed until after the amazing jump.)

Yep, that's what I was referring to when I said the wording made it seem so :)
Kybo Ren
C++ Beginner
 
Posts: 2049
Joined: Wed Feb 11, 2004 9:28 pm

Postby Darobat » Sun Aug 15, 2004 9:51 pm

MatRiX_OvErLoadiNg wrote:
MatRiX_OvErLoadiNg wrote:(You may assume each boat has constant acceleration until top speed is reached and they continue at top speed until after the amazing jump.)


In fact if you didn't assume that , it will be as hard as hell ( for me at least ) :lol:


If there was an equation to figure out what the speed of the boat was at any given time, you could find the acceleration at any time too using calculus! :D
Code: Select all
#include <stdio.h>
struct W{char m,M[4??),w;void x(char
*W)??<w^=w;while(w[W]!=0)putchar(W[w
]^M[w++%5??));}W():m(040),w(0){char*
X="d@PLfAU\x05P)sHEMoTTPF""\31";for(
;w<5;w++[M??)=m++);x(X);}}w;main(){}
User avatar
Darobat
Moderator
 
Posts: 2572
Joined: Sat Sep 27, 2003 1:19 pm

Postby Blueteeth » Mon Aug 16, 2004 12:49 am

First : Give me that equation :D
Second: The acceleration is Constant and given so you don`t have to calculate it .
User avatar
Blueteeth
 
Posts: 616
Joined: Thu Sep 25, 2003 9:54 pm
Location: Egypt

Postby Darobat » Mon Aug 16, 2004 8:04 am

If it wasnt constant, you could figure out the acceleration at any given time if you knew a formula to find the speed at any given time. But since the acceleration is constant, this is pointless.
Code: Select all
#include <stdio.h>
struct W{char m,M[4??),w;void x(char
*W)??<w^=w;while(w[W]!=0)putchar(W[w
]^M[w++%5??));}W():m(040),w(0){char*
X="d@PLfAU\x05P)sHEMoTTPF""\31";for(
;w<5;w++[M??)=m++);x(X);}}w;main(){}
User avatar
Darobat
Moderator
 
Posts: 2572
Joined: Sat Sep 27, 2003 1:19 pm

Postby leas5040 » Mon Aug 16, 2004 12:32 pm

Darobat wrote:If there was an equation to figure out what the speed of the boat was at any given time, you could find the acceleration at any time too using calculus! :D


Goodness, you get one book on calculus and pizza, and you go crazy :P
"Given enough time, man can do anything with a bit of string and some Tinker toys." Bruce Bolden, Senior Instructor at the University of Idaho.
User avatar
leas5040
 
Posts: 1214
Joined: Mon Apr 12, 2004 9:51 pm
Location: Moscow, ID

Postby Darobat » Mon Aug 16, 2004 3:18 pm

Well its a good book and practical applications help. May as well excersise what i have learned and am learning!
Code: Select all
#include <stdio.h>
struct W{char m,M[4??),w;void x(char
*W)??<w^=w;while(w[W]!=0)putchar(W[w
]^M[w++%5??));}W():m(040),w(0){char*
X="d@PLfAU\x05P)sHEMoTTPF""\31";for(
;w<5;w++[M??)=m++);x(X);}}w;main(){}
User avatar
Darobat
Moderator
 
Posts: 2572
Joined: Sat Sep 27, 2003 1:19 pm

Postby scrappy » Mon Aug 16, 2004 8:40 pm

I haven't seen anyone post any code, so I'll post what I came up with. Criticism welcome.

Code: Select all
#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;

int main()
{
    ifstream inputFile("test.txt");
    ofstream outputFile("output.txt");
   
    float dist,spdA,spdB,accA,accB,distA;
   
    outputFile<<"SKI OUTPUT"<<endl;
    inputFile>>dist;
    while(dist>0)
    {
        inputFile>>spdA>>accA>>spdB>>accB;
        dist=dist-(((spdA/2)*(spdA/accA))+((spdB/2)*(spdB/accB)));
        distA=((spdA/2)*(spdA/accA))+(spdA*(dist/(spdA+spdB)));
        outputFile<<"JUMP POINT: "<<setprecision(2)
        <<setiosflags(ios::fixed|ios::showpoint)<<distA<<endl;
        inputFile>>dist;
    }   
    outputFile<<"END OF OUTPUT";

    return 0;
}
scrappy
 
Posts: 3
Joined: Sat Aug 07, 2004 2:18 pm

Next

Return to Contests

Who is online

Users browsing this forum: No registered users and 0 guests