Maximum Multiple

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 xy and z such that: n=x+y+zxnynzn and xyz is maximum.
 

 

Input
There are multiple test cases. The first line of input contains an integer T (1T106), indicating the number of test cases. For each test case:
The first line contains an integer n (1n106).
 

 

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*n/27);
13         }else if(n%4==0){
14             printf("%lld\n",n*n*n/32);
15         }else{
16             puts("-1");
17         }
18     }
19     return 0;
20 }

 

posted @ 2018-07-25 10:53  #忘乎所以#  阅读(85)  评论(0编辑  收藏  举报