Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


A set of N billiard balls are set on a one-dimensional
table. The table is 1 meter long,

set north-south with two pockets at either side. Each ball
has zero width and there is

no friction so it is moving with a fixed velocity of either
northward or southward and

bounces back in a perfect elastic collision from other
balls it encounter on its way (or

drop into one of the pockets).


Your job is to keep track of the balls movements.

Task
Please write a program that gets the initial place, speed
and direction of all

the balls and gives the position of a specific ball after t
seconds.




Input
The first line contains the number of scenarios.

Each one of the other lines in the input contains a
scenario:

The first number, N, is the number of balls; followed by N
pairs of numbers: the

distance in centimeters from the south end of the table and
the speed (positive speed

meaning it moves northward); the last two numbers are the
number i of the target ball

you should track and the time T in seconds.


Output
The output is a single number for each line which is the
place (distance in centimeters

from the south end of the table) of the tracked ball after
T seconds.
Note: There is no new line character at the end of the
result.


Sample Input
5

1 50 1 1 1000

1 50 1 1 6

1 60 -2 1 6

2 10 1 95 -1 2 30

2 10 1 95 -1 2 60


Sample Output
100

56

48

65

70


No Answer is Posted For this Question
Be the First to Post Answer

Post New Answer

More C Interview Questions

Why c language is called c?

0 Answers  


Write a C program to help a HiFi’s Restaurant automate its breakfast billing system. Your assignment should implement the following items: a. Show the customer the different breakfast items offered by the HiFi’s Restaurant. b. Allow the customer to select more than one item from the menu. c. Calculate and print the bill to the customer. d. Produce a report to present your complete program and show more sample output. Assume that the HiFi’s Restaurant offers the following breakfast menu: Plain Egg $2.50 Bacon and Egg $3.45 Muffin $2.20 French Toast $2.95 Fruit Basket $3.45 Cereal $0.70 Coffee $1.50 Tea $1.80

0 Answers  


Explain what is the difference between a free-standing and a hosted environment?

0 Answers  


why programs in c are running with out #include<stdio.h>? some warnings are display in terminal but we execute the program we get answer why? eg: main() { printf("hello world "); }

0 Answers  


How can I do peek and poke in c?

0 Answers  


There are 3 baskets of fruits with worng lables,one basket has apple,another basket has orange,another has combination of apple and orange,what is the least way of interchange the lables.

15 Answers   Cisco, Google, MBT,


What is huge pointer in c?

0 Answers  


The difference between printf and fprintf is ?

0 Answers   Baan Infotech,


program to find the magic square

1 Answers   Infosys,


What is getch () for?

0 Answers  


What is the use of the restrict keyword?

1 Answers  


int x=sizeof(!5.856); What will value of variable x?

2 Answers  


Categories