Given length of sides of equilateral triangle (s), and velocities(v) of each animal tagged on the vertices of triangle, find out the time after which they meet, if they start moving towards their right opposite, forming a trajectory.

**Examples:**

Input : s = 2, v = 5 Output : 0.266667 Input : s = 11, v = 556 Output : 0.013189

**Approach : **

To find the total amount of time taken for the animals to meet, simply take A divided by the initial rate at which two vertices approach each other. Pick any two vertices, and it can be seen that the first point moves in the direction of the second at speed v, while the second moves in the direction of the first (just take the component along one of the triangle edges).

Reference : StackExchange

## C++

`// CPP code to find time ` `// taken by animals to meet ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// function to calculate time to meet ` `void` `timeToMeet(` `double` `s, ` `double` `v){ ` ` ` ` ` `double` `V = 3 * v / 2; ` ` ` ` ` `double` `time` `= s / V; ` ` ` ` ` `cout << ` `time` `; ` `} ` ` ` `// Driver Code ` `int` `main(` `void` `) { ` ` ` ` ` `double` `s = 25, v = 56; ` ` ` ` ` `timeToMeet(s, v); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java code to find time taken by animals ` `// to meet ` `import` `java.io.*; ` ` ` `public` `class` `GFG { ` ` ` ` ` `// function to calculate time to meet ` ` ` `static` `void` `timeToMeet(` `double` `s, ` `double` `v){ ` ` ` ` ` `double` `V = ` `3` `* v / ` `2` `; ` ` ` ` ` `double` `time = s / V; ` ` ` ` ` `System.out.println((` `float` `)time); ` ` ` `} ` ` ` ` ` `// Driver Code ` ` ` `static` `public` `void` `main (String[] args) ` ` ` `{ ` ` ` ` ` `double` `s = ` `25` `, v = ` `56` `; ` ` ` ` ` `timeToMeet(s, v); ` ` ` `} ` `} ` ` ` `//This code is contributed by vt_m. ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 code to find time ` `# taken by animals to meet ` ` ` `# function to calculate ` `# time to meet ` `def` `timeToMeet(s, v): ` ` ` `V ` `=` `3` `*` `v ` `/` `2` `; ` ` ` ` ` `time ` `=` `s ` `/` `V; ` ` ` ` ` `print` `(time); ` ` ` `# Driver Code ` `s ` `=` `25` `; ` `v ` `=` `56` `; ` ` ` `timeToMeet(s, v); ` ` ` `# This code is contributed by mits ` |

*chevron_right*

*filter_none*

## C#

`// C# code to find time ` `// taken by animals to meet ` `using` `System; ` ` ` `public` `class` `GFG { ` ` ` ` ` `// function to calculate time to meet ` ` ` `static` `void` `timeToMeet(` `double` `s, ` `double` `v){ ` ` ` ` ` `double` `V = 3 * v / 2; ` ` ` ` ` `double` `time = s / V; ` ` ` ` ` `Console.WriteLine((` `float` `)time); ` ` ` `} ` ` ` ` ` `// Driver Code ` ` ` `static` `public` `void` `Main () ` ` ` `{ ` ` ` ` ` `double` `s = 25, v = 56; ` ` ` ` ` `timeToMeet(s, v); ` ` ` ` ` `} ` `} ` ` ` `// This code is contributed by vt_m. ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP code to find time ` `// taken by animals to meet ` ` ` `// function to calculate ` `// time to meet ` `function` `timeToMeet(` `$s` `, ` `$v` `) ` `{ ` ` ` ` ` `$V` `= 3 * ` `$v` `/ 2; ` ` ` `$time` `= ` `$s` `/ ` `$V` `; ` ` ` `echo` `$time` `; ` `} ` ` ` ` ` `// Driver Code ` ` ` `$s` `= 25; ` `$v` `= 56; ` ` ` `timeToMeet(` `$s` `, ` `$v` `); ` ` ` `// This code is contributed by anuj_67. ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

0.297619

## Recommended Posts:

- Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle
- Area of circle which is inscribed in equilateral triangle
- Biggest Square that can be inscribed within an Equilateral triangle
- Largest hexagon that can be inscribed within an equilateral triangle
- Program to calculate area of Circumcircle of an Equilateral Triangle
- Time taken by two persons to meet on a circular track
- Program to calculate the Area and Perimeter of Incircle of an Equilateral Triangle
- Largest square that can be inscribed within a hexagon which is inscribed within an equilateral triangle
- Area of a square inscribed in a circle which is inscribed in an equilateral triangle
- Minimum time required to fill a cistern using N pipes
- Minimum time required to complete a work by N persons together
- Probability that two persons will meet
- Biggest Reuleaux Triangle within a Square which is inscribed within a Right angle Triangle
- Check if two people starting from different points ever meet
- Find if two people ever meet after same number of jumps

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.