码迷,mamicode.com
首页 > 其他好文 > 详细

HDU6298 Maximum Multiple

时间:2018-10-04 10:02:54      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:return   type   cstring   maximum   ace   can   color   tin   mes   

思路:多写几个数会发现,只有n%3==0和n%4==0的情况下满足题意。

#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(void)
{
    ll n;
    ll t;
    scanf("%lld",&t);
    while(t--)
    {
        scanf("%lld",&n);
        if(n<3)
            printf("-1\n");
        else
        {
            if(n%3==0)
            {
                printf("%lld\n",n/3*n/3*n/3);
                continue;
            }
            if(n%4==0)
            {
                printf("%lld\n",n/4*n/4*n/2);
            }
            else
                printf("-1\n");
        }
    }
    return 0;
} 

 

HDU6298 Maximum Multiple

标签:return   type   cstring   maximum   ace   can   color   tin   mes   

原文地址:https://www.cnblogs.com/AC-AC/p/9739663.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!