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. 把MP3保存到数据库中

    使用JdbcUtils得到连接con java.sql包下的Interface Blob----其实现类SerialBlob Blob是一个可以存储二进制文件的容器. BLOB常常是数据库中用来存储二 ...

  2. DBCHART

    dbchart1.Series[0].DataSource := adoquery1; dbchart1.Series[0].XLabelsSource := 'aaaa'; dbchart1.Ser ...

  3. Linux and Oracle常用目录详解

    目录详解 目录 内容 / 根目录,一切从这里开始 /bin 包含系统启动和运行所必需的二进制文件(程序) /boot 包含Linux内核.最初的RAM磁盘映像(系统启动时,驱动程序会用到),以及启动加 ...

  4. springboot注入properties配置到javabean

    一.再application.properties中添加 二. @Value("${field}")在字段上面加个注解

  5. scrapy windows下出现importError:No module named 'win32api'

    scrapy windows下出现importError:No module named 'win32api'需安装 pip install pypiwin32

  6. 并查集——易爆物D305

    部分内容摘自博客http://blog.csdn.net/u012881011/article/details/46883863,感谢 易爆物D305             运行时间限制:1000m ...

  7. 基于fiddler实现本地代理完成脚本测试

    配置好fiddler以后,具体操作流程如下: 1.找到后在右边点击AutoResponder,查看,默认情况如下 勾选 2.ctrl+F 搜索 app. 关键字 ,找到后拖到右侧 3.替换本地文件 4 ...

  8. 自动化工具之二:win32gui

    自动化工具win32gui 一.下载安装win32gui 二.Win32gui的使用 1.查找窗体句柄 我们知道的所有空间其实就是窗体,所有的窗口都有一个独立的句柄,要操作任意一个窗体,你都需要找到这 ...

  9. VS2017使用Git进行源代码管理

    步骤一:将解决方案添加到源代码管理 步骤二:进入团队资源管理器 双击存储库项目进入Git操作页面. 步骤三:同步本地代码到远程仓库 选择同步功能 步骤四:发布代码到Git 点击之后输入你要发布的git ...

  10. NYOJ 会场安排问题

    #include<iostream> #include<stdio.h> #include<string.h> #include<queue> #inc ...