0
点赞
收藏
分享

微信扫一扫

【HDU 6298】Maximum Multiple

夕阳孤草 2022-07-04 阅读 50

1.​​题目链接​​。找一下规律,其实看看看i,j,k的性质,发现最优的比例一般都是1:1:1或者1:1:2.

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#pragma warning(disable:4996)
int main()
{
int T;
scanf("%d", &T);
while (T--)
{
ll n;
scanf("%lld", &n);
ll mmax = -1;
if (n % 3 == 0)
{
ll tem = n / 3;
mmax = max(tem*tem*tem, mmax);
}
if (n % 4 == 0)
{
ll tem1 = n / 2;
ll tem2 = n / 4;
mmax = max(mmax, tem1*tem2*tem2);
}
cout << mmax << endl;
}
}

 


举报

相关推荐

0 条评论