Question 4: Jogging Ground

Problem Description

There are 4 circular grounds of equal sizes. Their circumferences do not intersect. The radius and the distance of the center of each circle from the leftmost circle’s center are given.

There are 4 joggers who can start at the same time from any of the points designated as { a, b, c, d } on the circumference of all the four circles as shown in the diagram below. All 4 joggers jog in different grounds along the circumference of that ground. They could jog in either clockwise (left to right) or anticlockwise (right to left) direction. Finally they may also jog at different speeds.

Given starting position, direction of jogging and speed of jogging of all the 4 joggers, find the summation of length of 3 segments between the four joggers at a given point in time since the start of the jog.

Note : All the computation has to be accurate up to 6 digits after the decimal point.

Input

First line contains 4 integers each denoting the following

R denotes the radius of all four circles

D1 denotes the distance centre of the second circle from left to the centre of the leftmost circle

D2 denotes the distance centre of the third circle from left to the centre of the leftmost circle

D3 denotes the distance centre of the last circle from left to the centre of the leftmost circle

Second line contains 4 space separated integers denoting the angle with point a of each of the 4 circles where 0 degree indicates point a itself, 90 degree indicates point b, 180 degree indicates point c and 270 degree indicates point d.

Third line contains 4 space separated integers denoting the velocity in degrees per second.

Fourth line contains 4 space separated integers denoting the direction of running for joggers (0=clockwise and 1=anticlockwise).

Fifth Line contains integer N denoting the time in seconds since the start of the jog.

Output

Print the summation of length of 3 segments between the four joggers after N seconds, rounded to the nearest integer.

Examples

Input : 10 25 50 75

0 0 0 0

1 1 1 1

1 1 1 1

90

Output : 75

Input : 10 25 50 75

0 0 0 0

1 2 3 4

0 0 0 0

90

Output : 91

TCS Codevita 9 Pre-qualifier round questions

TCS Codevita Pre-qualifier Round which was held on 15th August 2020 by TCS to filter out the candidates that suits  there company as  Software Engineers. The level of this Coding Round was medium and not that easy. Every candidate has to solve atleast one question to be qualified for the next round. The coding round comprised of good set of questions which are as follows :

Similar Reads

Question 1: String Pair

Problem Description...

Question 2: Elections

Problem Description...

Question 3: Moving Average

Problem Description...

Question 4: Jogging Ground

Problem Description...

Question 5: Zoo Design

Problem Description...

Contact Us