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. python发送邮件 大全汇总

    https://blog.csdn.net/bmxwm/article/details/79007871 参考菜鸟教程发送只有文字的邮件 1 2 3 4 5 6 7 8 9 10 11 12 13 1 ...

  2. python 随机模块常用命令

    import randomprint(random.random()) #用于生成一个0到1之间的随机浮点数print(random.uniform(1,3))# 用于生成一个指定范围内的随机浮点数p ...

  3. 去除字符串中的html代码

    public static String Html2Text(String inputString) { String htmlStr = inputString; // 含html标签的字符串 St ...

  4. 1-3-编译Linux内核

    1-3-编译Linux内核 1.将Linux源码包拷贝到共享文件夹. 2.进入共享文件夹. 3.解压,命令#tar xvfj Kernel_3.0.8_TQ210_for_Linux_v2.2.tar ...

  5. 小程序支持连Wi-Fi,代码包到4M

    小程序又开发新能力了:1 更多硬件连接功能等着你.在商场等场所,用户以往要用微信连Wi-Fi,要扫二维码并关注公众号,点击菜单里的“连Wi-Fi”才能使用上网络.连个Wi-Fi何必让用户经过两道坎? ...

  6. pycharm如何设置注释的字体颜色

    一.pycharm如何设置注释的字体颜色 1.打开pycharm编辑器,file > settings > Editor > Color Scheme > python > ...

  7. GIT中常用的命令

    最近项目中使用到了GIT,所以记录一下GIT中常用的命令. GIT使用的客户端有Git Bash:http://code.google.com/p/msysgit/ 还有乌龟TortoiseGit:h ...

  8. linux下禁止root远程登录和添加新用户

    https://www.cnblogs.com/jianz/p/7979250.html 一.添加和root权限一样的用户 1. adduser admin passwd  admin (修改密码) ...

  9. ROSETTA使用技巧随笔--RosettaLigand Docking

    时间不充分,简单记录下自己实践过程中的做法: 1. 首先,非标准残基都需要转换成.params文件,使用 <path-to-Rosetta>/main/source/scripts/pyt ...

  10. ios UrlEncode与UrlDecode

    url字符串中具有特殊功能的特殊字符的字符串,或者中文字符,作为参数用GET方式传递时,需要用urlencode处理一下.当然,有时作为Post参数传递,也需要urlencode处理一下. NSStr ...