HDU 6298 (找规律)

题意:
n=x+y+z,x|n,y|n,z|n,求max(xyz)

思路:
打表找规律

代码:

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <sstream>
#define pb push_back
#define X first
#define Y second
#define lch (o<<1)
#define rch (o<<1|1)
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define pii pair<int,int>
#define qclear(a) while(!a.empty())a.pop();
#define lowbit(x) (x&-x)
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sddd(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define mst(a,b) memset(a,b,sizeof(a))
#define cout3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define cout2(x,y) cout<<x<<" "<<y<<endl
#define cout1(x) cout<<x<<endl
#define IOS std::ios::sync_with_stdio(false)
#define SRAND srand((unsigned int)(time(0)))
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
using namespace std;
const double PI=acos(-1.0);
const int INF=0x3f3f3f3f;
const ll mod=1e9+7;
const double eps=1e-8;
const int maxn=100005;
const int maxm=10005;

//int fac[maxn];
void solve() {
    int t;
    sd(t);
    while(t--){
        int n;
        sd(n);
        if(n%3==0){
            ll ans=(ll)n/3*n/3*n/3;
            printf("%lld\n",ans);
        }else if(n%4==0){
            ll ans=(ll)n/2*n/4*n/4;
            printf("%lld\n",ans);
        }else{
            printf("-1\n");
        }
    }
//    for(int n=1;n<10;n++){
//        int cur=0;
//        for(int i=1;i<=n;i++){
//            if(n%i==0)fac[cur++]=i;
//        }
//        int ans=-1;
//        for(int i=0;i<cur;i++){
//            for(int j=0;j<cur;j++){
//                for(int k=0;k<cur;k++){
//                    if(fac[i]+fac[j]+fac[k]==n){
//                        ans=max(ans,fac[i]*fac[j]*fac[k]);
//                    }
//                }
//            }
//        }
//        cout2(n,ans);
//    }
    return ;
}
int main() {
#ifdef LOCAL
    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
#else
    //    freopen("","r",stdin);
    //    freopen("","w",stdout);
#endif
    solve();
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值