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).
 
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
 
 
题目意思:给你n个数,要你找出X,Y,Z, X+Y+Z = n,并且 X,Y, Z 是 n 的一个因子(我当时不认识“ | ”这个符号,想了半天), 输出X * Y * Z 的最大值。
题解:X + Y + Z = n 两边同时除以n, 得到 x/n + y/n + z/n = 1,分别设为 a,b,c; 1/3 + 1/3 +1/3 = 1    1/2 + 1/3+ 1/6  1/2 + 1/4 + 1/4 = 1。另外套for循环 打表发现 必须是3 和 4的倍数才符合题意。 所以就是 1 3 两种情况满足题意。
 
 #include <iostream>
using namespace std;
typedef long long ll; int main(){
int T;
scanf("%d",&T);
while(T--){
ll n;
ll max = ;
scanf("%lld",&n);
if(n% == ){
max = n*n*n/;cout<<max<<endl;
} else if(n% == ){
max = n*n*n/;cout<<max<<endl;
} else
cout<<"-1"<<endl; }
return ;
}

HDU 6298的更多相关文章

  1. HDU 6298.Maximum Multiple-数学思维题(脑子是个好东西,可惜我没有) (2018 Multi-University Training Contest 1 1001)

    暑假杭电多校第一场,这一场是贪心场,很多贪心的题目,但是自己太菜,姿势挫死了,把自己都写吐了... 2018 Multi-University Training Contest 1 HDU6298.M ...

  2. hdu 6298 Maximum Multiple (简单数论)

    Maximum Multiple Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  3. HDU 6298(数学)

    题意是给出一个数,找出这个数的三个因子且这三个因子的和等于这个数,输出满足条件的乘积最大的一组因子的乘积,如果不存在这样的因子,就输出 -1. 第一次 wa 了,因为把题目中的 x | n 当做了位或 ...

  4. hdu 6298 Maximum Multiple(规律)

    hdu6298 Maximum Multiple 题目传送门 题意: 给你一个整数n,从中找出可以被n整除的三个数x,y,z: 要求x+y+z=n,且x*y*z最大. 思路: 开始一看T到1e6,n也 ...

  5. 2018 Multi-University Training Contest - Team 1 题解

    Solved A HDU 6298 Maximum Multiple Solved B HDU 6299 Balanced Sequence Solved C HDU 6300 Triangle Pa ...

  6. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  7. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  8. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  9. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

随机推荐

  1. minikube k8 ingress--https://kubernetes.io/docs

    https://ehlxr.me/2018/01/12/kubernetes-minikube-installation/[Kubernetes 学习笔记之 MiniKube 安装 in CHINA] ...

  2. swf 文件解析

    public class TagTypes     {         // Flash 1 tags         public static const TAG_END:uint = 0;    ...

  3. hadoop 学习笔记2

    ============Hive vs Hadoop============== Hive是建立在Hadoop之上为了减少MapReduce jobs编写工作的批处理系统,HBase是为了支持弥补Ha ...

  4. python3实现字符串的全排列的方法(无重复字符)

    https://www.jb51.net/article/143357.htm 抛出问题 求任意一个字符串的全排列组合,例如a='123',输出 123,132,213,231,312,321.(暂时 ...

  5. struct和[]byte的转换,注意结构体内变量首字母一定大写

    type temp struct {     Afd int     Bee string }func main(){ text:=temp{3123,"4234"} b._:=j ...

  6. python下载youtube视频

    谷歌开源了一个新的数据集,BoundingBox,(网址在这里)这个数据集是经过人工标注的视频数据集,自然想将它尽快地运用在实际之中,那么首先需要将其下载下来:可以看到网址上给出的是csv文件,该文件 ...

  7. rm:删除目录和文件

    [root@linux-node- sss]# rm soft.txt //删除文件 rm: remove regular empty file ‘soft.txt’? y [root@linux-n ...

  8. Magento2与Magento1的区别有哪些

    magento2是15年正式上线的正式版,框架和写法跟magento1有很大区别,用到了命名空间和composer,模块化设计更强.因为是刚出生不久 所以bug比较多.目前全世界做magento2的公 ...

  9. RN NetInfo使用

    代码: class NetInfoView extends Component { getNetInfo() { //如果是andorid的程序,需要在xml添加获取网络请求权限 NetInfo.fe ...

  10. 如何卸载docker

    1.卸载 (1)yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ d ...