Maximum Multiple
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1576 Accepted Submission(s): 677
Problem Description
Given an integer n, Chiaki would like to find three positive integers x, y and z such that: n=x+y+z, x∣n, y∣n, z∣n and xyz is maximum.
Input
There are multiple test cases. The first line of input contains an integer T (1≤T≤106), indicating the number of test cases. For each test case:
The first line contains an integer n (1≤n≤106).
The first line contains an integer n (1≤n≤106).
Output
For each test case, output an integer denoting the maximum xyz. If there no such integers, output −1 instead.
Sample Input
3
1
2
3
Sample Output
-1
-1
1
Source
1 #include <iostream> 2 3 using namespace std; 4 5 int main(){ 6 int t; 7 long long int n; 8 scanf("%d",&t); 9 while(t--){ 10 scanf("%lld",&n); 11 if(n%3==0){ 12 printf("%lld ",n*n*n/27); 13 }else if(n%4==0){ 14 printf("%lld ",n*n*n/32); 15 }else{ 16 puts("-1"); 17 } 18 } 19 return 0; 20 }