博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1001 Maximum Multiple(2018 Multi-University Training Contest 1)
阅读量:4589 次
发布时间:2019-06-09

本文共 1319 字,大约阅读时间需要 4 分钟。

Maximum Multiple

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

Total Submission(s): 3985    Accepted Submission(s): 926

Problem Description
Given an integer 
n, Chiaki would like to find three positive integers xy and z such that: n=x+y+zxnynzn and xyz is maximum.
 
Input
There are multiple test cases. The first line of input contains an integer 
T (1T106), indicating the number of test cases. For each test case:
The first line contains an integer n (1n106).
 
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,满足n=x+y+z, 并且x , y , z能整除n,求满足条件的x,y,z的max(x,y,z)
 
分析: 首先理解整数
1分成三个分子为
1的分数和,仅有两种(1/3,1/3,1/3),(1/2,1/4,1/4)
所以要将n分解成三份并且能整除的话就只能分成(n/3,n/3,n/3),(n/2,n/4,n/4)
 
只需要判断n能不能被3或者4整除
 
1 #include 
2 using namespace std; 3 4 int t; 5 long long n; 6 7 int main() 8 { 9 scanf("%d",&t);10 while(t--) {11 scanf("%d",&n);12 if(n%3 == 0) {13 printf("%lld\n",n/3*n/3*n/3);14 } else if(n%4 == 0) {15 printf("%lld\n",n/2*n/4*n/4);16 } else {17 printf("-1\n");18 }19 }20 21 return 0;22 }

 

 

转载于:https://www.cnblogs.com/nothing-fun/p/9387717.html

你可能感兴趣的文章
jmeter生成随机的四位数
查看>>
Jmeter做接口的压力测试
查看>>
sql语句优化的30种方法
查看>>
MyISAM和InnoDB的区别
查看>>
springboot2.0 management.security.enabled无效
查看>>
spring cloud启动zipkin,报错maven依赖jar包冲突 Class path contains multiple SLF4J bindings
查看>>
源发行版8需要目标发行版1.8
查看>>
Cleartext HTTP traffic to xxx not permitted解决办法
查看>>
[Docker] Win10中安装Docker并运行Nginx镜像
查看>>
pxe批量装机
查看>>
linux典型应用对系统资源使用的特点
查看>>
linux性能分析工具Procs
查看>>
linux性能分析工具Vmstat
查看>>
linux性能分析工具Memory
查看>>
c# 选择结构
查看>>
c# 委托
查看>>
c# 接口使用
查看>>
c# 事件
查看>>
c# as运算符
查看>>
c# 调试过程
查看>>