Skip to content

Commit c311472

Browse files
authored
Create Maximize the product.txt
1 parent d57e86d commit c311472

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Given an integer N, the task is to find the maximum product of A, B, C, D such that below conditions satisfy:
2+
3+
N%A ==0 && N%B ==0 && N%C ==0 && N%D ==0.
4+
Maximize the product A*B*C*D where N = A+B+C+D.
5+
If no solution exists, print ‘-1’ (without quotes).
6+
7+
Examples:
8+
9+
Input: N = 8
10+
Output: 16
11+
The divisors of 8 are {1, 2, 4, 8}.
12+
The maximized product can be formed
13+
by multiplying 2*2*2*2 = 16 as 2+2+2+2 = 8.
14+
15+
Input: N = 4
16+
Output: 1
17+
The divisors of 4 are {1, 2, 4}.
18+
The maximized product can be formed
19+
by multiplying 1*1*1*1 = 1 as 1+1+1+1 =4.

0 commit comments

Comments
 (0)