Detachment
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 570 Accepted Submission(s): 192
Problem DescriptionIn a highly developed alien society, the habitats are almost infinite dimensional space. In the history of this planet,there is an old puzzle. You have a line segment with x units’ length representing one dimension.The line segment can be split into a number of small line segments: a1,a2, … (x= a1+a2+…) assigned to different dimensions. And then, the multidimensional space has been established. Now there are two requirements for this space: 1.Two different small line segments cannot be equal ( ai≠aj when i≠j).2.Make this multidimensional space size s as large as possible (s= a1∗a2*...).Note that it allows to keep one dimension.That's to say, the number of ai can be only one.Now can you solve this question and find the maximum size of the space?(For the final number is too large,your answer will be modulo 10^9+7)
InputThe first line is an integer T,meaning the number of test cases. Then T lines follow. Each line contains one integer x. 1≤T≤10^6, 1≤x≤10^9
OutputMaximum s you can get modulo 10^9+7. Note that we wants to be greatest product before modulo 10^9+7.
Sample Input1 4
Sample Output4
Source
Recommendwange2014 | We have carefully selected several similar problems for you:
| | |
题目链接:
题目大意:
给一个数N(N<=109),让你把它拆成若干各不相同的数Ai,ΣAi=N,要求ΠAi(累乘)最大。
题目思路:
【贪心】
首先肯定要把位数拆的尽量多,手写了20以内的拆法。
发现以2为首相的递增序列累乘最大,所以我的想法就是把N拆成2+3+...+x<=n,
先找到x,之后算一下n还多了多少,就把后面依次+1,变成2+3+...+y+(y+2)+(y+3)+...+(x+1)。
这时候它们的累乘是最大的。
(特殊情况是从2到x都加1之后还剩余1,这时候把最后一项再加1,变成3+4+...+x+(x+2)
1 // 2 //by coolxxx 3 /* 4 #include5 #include 6 #include 7 #include 8 #include