Divide Number

3.9

81 votes
Algorithms, Depth First Search, Medium, String Manipulation
Problem

Given integer N, you need to find four integers A,B,C,D, such that they're all factors of N (A|N,B|N,C|N,D|N), and N=A+B+C+D. Your goal is to maximize A×B×C×D.

Input format

First line contains an integer T(1T4104), represents the number of test cases.

Each of the next T lines contains an integer N (1N4104, N4 will not exceed 64 bit integer).

Output format

T lines, each line contains the answer (A×B×C×D) to correspond test case. If there is no way to find such four numbers, output 1.

Sample Input
1
8
Sample Output
16
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

A=B=C=D=2

Editor Image

?