Minimum time required to complete a work by N persons together | C ++ implementation of above approach ; Function to calculate the time ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; float calTime ( float arr [ ] , int n ) { float work = 0 ; for ( int i = 0 ; i < n ; i ++ ) work += 1 / arr [ i ] ; return 1 / work ; } int main ( ) { float arr [ ] = { 6.0 , 3.0 , 4.0 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << calTime ( arr , n ) << " ▁ Hours " ; return 0 ; }