Algorithm


A. Parallelepiped
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You've got a rectangular parallelepiped with integer edge lengths. You know the areas of its three faces that have a common vertex. Your task is to find the sum of lengths of all 12 edges of this parallelepiped.

Input

The first and the single line contains three space-separated integers — the areas of the parallelepiped's faces. The area's values are positive ( > 0) and do not exceed 104. It is guaranteed that there exists at least one parallelepiped that satisfies the problem statement.

Output

Print a single number — the sum of all edges of the parallelepiped.

Examples
input
Copy
1 1 1
output
Copy
12
input
Copy
4 6 6
output
Copy
28
Note

In the first sample the parallelepiped has sizes 1 × 1 × 1, in the second one — 2 × 2 × 3.



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <bits/stdc++.h>

using namespace std;

int a[3], b[3];
vector<int> d[3];

int main() {
  for(int i = 0; i < 3; ++i)
    scanf("%d", a + i);
  sort(a, a + 3);

  for(int i = 0; i < 3; ++i) {
    int sqrta = sqrt(a[i]) + 1;
    for(int j = 1; j <= sqrta; ++j) {
      if(a[i] % j == 0)
        d[i].push_back(j), d[i].push_back(a[i] / j);
    }
  }

  for(int i = 0; i < d[0].size(); ++i)
    for(int j = 0; j < d[1].size(); ++j)
      for(int k = 0; k < d[2].size(); ++k) {
        b[0] = d[0][i] * d[1][j];
        b[1] = d[0][i] * d[2][k];
        b[2] = d[1][j] * d[2][k];
        sort(b, b + 3);

        bool ok = true;
        for(int l = 0; l < 3; ++l)
          if(a[l] != b[l])
            ok = false;
        
        if(ok) {
          printf("%d\n", 4 * d[0][i] + 4 * d[1][j] + 4 * d[2][k]);
          return 0;
        }
      }

  return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
1 1 1

Output

x
+
cmd
12
Advertisements

Demonstration


Codeforcess Solution Parallelepiped, A. Parallelepiped ,C,C++, Java, Js and Python ,Parallelepiped,Codeforcess Solution

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+