Time required to meet in equilateral triangle

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

Recommended: Please try your approach on {IDE} first, before moving on to the solution.

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 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; }

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.

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

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.

PHP



Output:

0.297619

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

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.

Improved By : vt_m, Mithun Kumar

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.
{"ft_lang_label":"__label__en","ft_lang_prob":0.82162344,"math_prob":0.9466776,"size":3947,"snap":"2019-43-2019-47","text_gpt3_token_len":1087,"char_repetition_ratio":0.13745879,"word_repetition_ratio":0.2204301,"special_character_ratio":0.2786927,"punctuation_ratio":0.12125341,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97699976,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,8,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-10-14T03:54:03Z\",\"WARC-Record-ID\":\"<urn:uuid:c60ffc83-95c7-46ca-916f-b1b84d853225>\",\"Content-Length\":\"118902\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:186594b3-0706-44a3-a79e-8925b56000aa>\",\"WARC-Concurrent-To\":\"<urn:uuid:a0ef217c-380e-406f-91a7-2f3c07ec1159>\",\"WARC-IP-Address\":\"23.62.7.153\",\"WARC-Target-URI\":\"https://www.geeksforgeeks.org/time-meet-animals/\",\"WARC-Payload-Digest\":\"sha1:3DXYRZHT7TR6RQC5SCGRHZ3K4FPXQ645\",\"WARC-Block-Digest\":\"sha1:4Q3N7FVNOQE7FW7TYNVKEBCWI4J7EN7B\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-43/CC-MAIN-2019-43_segments_1570986649035.4_warc_CC-MAIN-20191014025508-20191014052508-00489.warc.gz\"}"}