题意大致是给你一个整数n,让你确定是否有三个正整数x,y,z既能被n整除,又能x+y+z=n,并使xyz最大
从中根据规律可以看出,只有被3或被4整除的数才能满足题目要求
被3整除的最大值为n^3/3^3
被4整除的最大值为n^3/(2*4*4)
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
1
2
3
Sample Output
-1 -1 1
#include <iostream> using namespace std; int main()
{
ios::sync_with_stdio(false);
int t;
cin >> t;
while (t--)
{
long long n;
cin >> n;
if (n % == )
cout << (n / )*(n / )*(n / ) << endl;
else if (n % == )
cout << (n / )*(n / )*(n / ) << endl;
else
cout << "-1" << endl;
}
return ;
}