Given an integer nn, Chiaki would like to find three positive integers xx, yy and zzsuch that: n=x+y+zn=x+y+z, x∣nx∣n, y∣ny∣n, z∣nz∣n and xyzxyz is maximum.

Input

There are multiple test cases. The first line of input contains an integer TT (1≤T≤1061≤T≤106), indicating the number of test cases. For each test case:
The first line contains an integer nn (1≤n≤1061≤n≤106).

Output

For each test case, output an integer denoting the maximum xyzxyz. If there no such integers, output −1−1 instead.

Sample Input

3
1
2
3

Sample Output

-1
-1
1

只有因子中有4或者有3才能被拆成 X+Y+Z=N,然后打了表验证。
最后wa了好几次,是因为int和int计算之后还是int就算赋值给long long .
打表代码

#include <bits/stdc++.h>
using namespace std;
int main()
{int T;scanf("%d", &T);while (T--){int n;for (int n = 1; n <= 100; n++){int maxt = -1;int a, b, c;for (int x = 1; x <= n; x++){for (int y = 1; y <= n - x; y++){int z = n - x - y;if (z && n % x == 0 && n % y == 0 && n % z == 0){if (maxt < x * y * z){a = x;b = y;c = z;}maxt = max(maxt, x * y * z);}}}printf("%d:%5d %d %d %d\n", n, maxt, a, b, c);if (n % 12 == 0)printf("\n");}}return 0;
}

AC

#include <bits/stdc++.h>
using namespace std;
int main()
{int T;long long  n,x,y,z;long long sum;scanf("%d", &T);while (T--){scanf("%lld", &n);if ((n % 3) == 0){x = y = z = n / 3;sum = x * y * z;if (x + y + z == n)printf("%lld\n", sum);elseputs("-1");}else if ((n % 4) == 0){x = y = n / 4, z = n / 2;sum = x * y * z;if (x + y + z == n)printf("%lld\n", sum);elseputs("-1");}elseputs("-1");}
}

数学--数论--HDU-2698 Maximum Multiple(规律)相关推荐

  1. 数学--数论--HDU 2582 F(N) 暴力打表找规律

    This time I need you to calculate the f(n) . (3<=n<=1000000) f(n)= Gcd(3)+Gcd(4)+-+Gcd(i)+-+Gc ...

  2. 数学--数论--HDU - 6322 打表找规律

    In number theory, Euler's totient function φ(n) counts the positive integers up to a given integer n ...

  3. 数学--数论--HDU 2197 本原串 (推规律)

    由0和1组成的串中,不能表示为由几个相同的较小的串连接成的串,称为本原串,有多少个长为n(n<=100000000)的本原串? 答案mod2008. 例如,100100不是本原串,因为他是由两个 ...

  4. 数学--数论--HDU - 6395 Let us define a sequence as below 分段矩阵快速幂

    Your job is simple, for each task, you should output Fn module 109+7. Input The first line has only ...

  5. 数学--数论--Hdu 5793 A Boring Question (打表+逆元)

    There are an equation. ∑0≤k1,k2,⋯km≤n∏1⩽j<m(kj+1kj)%1000000007=? We define that (kj+1kj)=kj+1!kj! ...

  6. 数学--数论--HDU 12151七夕节 Plus (因子和线性筛)

    Problem Description 七夕节那天,月老来到数字王国,他在城门上贴了一张告示,并且和数字王国的人们说:"你们想知道你们的另一半是谁吗?那就按照告示上的方法去找吧!" ...

  7. 数学--数论-- HDU 2601 An easy problem(约束和)

    Problem Description When Teddy was a child , he was always thinking about some simple math problems ...

  8. 数学--数论--HDU 6128 Inverse of sum (公式推导论)

    Description 给nn个小于pp的非负整数a1,-,na1,-,n,问有多少对(i,j)(1≤i<j≤n)(i,j)(1≤i<j≤n)模pp在意义下满足1ai+aj≡1ai+1aj ...

  9. 数学--数论--HDU 4675 GCD of Sequence(莫比乌斯反演+卢卡斯定理求组合数+乘法逆元+快速幂取模)

    先放知识点: 莫比乌斯反演 卢卡斯定理求组合数 乘法逆元 快速幂取模 GCD of Sequence Alice is playing a game with Bob. Alice shows N i ...

  10. 数学--数论--HDU 2674 沙雕题

    WhereIsHeroFrom: Zty, what are you doing ? Zty: I want to calculate N!.. WhereIsHeroFrom: So easy! H ...

最新文章

  1. [转载] 大道至简:软件工程实践者的思想——第四章 流于形式的沟通
  2. python主流版本-python主流版本
  3. 安装vsftpd-3.0.2.tar.gz源码
  4. 【微信小程序】根据当前运行环境调用不同的接口地址的一些方法
  5. 产品推广系统推荐乐云seo_优化推广公司红利产品推荐“爱采购cpc竞价版”
  6. Vue 路由router的两种模式
  7. json api_JSON模式在构建和部署API中的作用
  8. mysql 写入随机字中文符_MySQL产生随机字符
  9. eclipse没有java web,Java-我的Eclipse IDE中缺少Web服务选项
  10. C语言中断函数c_int00的作用,关于DSP程序中的_c_int00含义
  11. android版usb转网线驱动,usb网线转换器驱动下载
  12. python 保存scv文件乱码与报错的问题解决TypeError: a bytes-like object is required, not 'str'
  13. 3dmax Maxscript 回调脚本异常
  14. 项目管理十大知识领域之项目范围管理
  15. 什么叫结构化程序设计?它的主要内容是什么
  16. 中国图书分类法检索计算机方面的图书,《中国图书分类法》(简称《中图法》)是我国常用的分类法,要检索计算机方面的图书,需要在( )类目下查找。...
  17. 电信副卡显示无服务器,电信副卡,你从来就是一个陷阱吗?
  18. 关于5G,你必须知道的事儿……
  19. win10 屏幕保护时间到了不触发_你真的了解Win10么?网友教你玩转Win10!
  20. 苹果的「AI 建筑师」GAUDI:根据文本生成 3D 场景

热门文章

  1. You must supply a resourceID for a TextView
  2. 作用域js和java区别_js作用域理解
  3. 大道至简,阿里巴巴敏捷教练的电子看板诞生记
  4. [AlwaysOn Availability Groups]CLUSTER.LOG(AG)
  5. [NHibernate]获取分组查询的记录总数
  6. 如何删除子域信任关系?
  7. 前端session存储实例
  8. linux中用户与组的概念,Linux用户和组的概念
  9. 云鲸扫拖一体机器人说明书_云鲸扫拖一体机器人开箱测评。拖地机器人的天花板是什么样的?...
  10. c语言编程 验证用户名和密码是否正确(函数定义),《C语言程序设计教程》习题参考答案[精品资料].doc...