Detachment

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 570    Accepted Submission(s): 192

Problem Description
In 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)
 
Input
The 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
 
Output
Maximum s you can get modulo 10^9+7. Note that we wants to be greatest product before modulo 10^9+7.
 
Sample Input
1
4
 
Sample Output
4
 
Source
 
Recommend
wange2014   |   We have carefully selected several similar problems for you:  6010 6009 6008 6007 6006 
 

Statistic | Submit | Discuss | Note

题目链接:

  http://acm.hdu.edu.cn/showproblem.php?pid=5976

题目大意:

  给一个数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)

 //
//by coolxxx
/*
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<memory.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
//#include<stdbool.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
*/
#include<bits/stdc++.h>
#pragma comment(linker,"/STACK:1024000000,1024000000")
#define abs(a) ((a)>0?(a):(-(a)))
#define lowbit(a) (a&(-a))
#define sqr(a) ((a)*(a))
#define mem(a,b) memset(a,b,sizeof(a))
#define eps (1e-8)
#define J 10000
#define mod 1000000007
#define MAX 0x7f7f7f7f
#define PI 3.14159265358979323
#define N 45004
using namespace std;
typedef long long LL;
double anss;
LL aans;
int cas,cass;
int n,m,lll,ans;
LL a[N],ni[N];
LL mi(LL x,LL y)
{
LL z=;
while(y)
{
if(y&)z=(z*x)%mod;
x=(x*x)%mod;
y>>=;
}
return z;
}
void init()
{
int i;
a[]=;
ni[]=;
for(i=;i<N;i++)
{
a[i]=(a[i-]*i)%mod;
ni[i]=(-(mod/i)*a[mod%i])%mod;
}
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
// freopen("2.txt","w",stdout);
#endif
int i,j,k;
int x,y,z;
init();
for(scanf("%d",&cass);cass;cass--)
// for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
// while(~scanf("%s",s))
// while(~scanf("%d%d",&n,&m))
{
scanf("%d",&n);
if(n<)
{
printf("%d\n",n);
continue;
}
m=n+n+;
LL l,r,mid;
l=;r=;
while(l<r)
{
mid=(l+r+)>>;
if(mid*mid+mid<=m)l=mid;
else r=mid-;
}
m-=l*l+l;
m/=;
if(m==l)
{
aans=a[l]*(l+)%mod*mi(,mod-)%mod;
}
else
{
x=l+-m;
aans=a[l+]*mi(x,mod-)%mod;
}
printf("%lld\n",aans);
}
return ;
}
/*
// //
*/

HDU 5976 Detachment 【贪心】 (2016ACM/ICPC亚洲区大连站)的更多相关文章

  1. HDU 5979 Convex【计算几何】 (2016ACM/ICPC亚洲区大连站)

    Convex Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Subm ...

  2. 2016ACM/ICPC亚洲区大连站现场赛题解报告(转)

    http://blog.csdn.net/queuelovestack/article/details/53055418 下午重现了一下大连赛区的比赛,感觉有点神奇,重现时居然改了现场赛的数据范围,原 ...

  3. 2016ACM/ICPC亚洲区大连站-重现赛

    题目链接:http://acm.hdu.edu.cn/search.php?field=problem&key=2016ACM%2FICPC%D1%C7%D6%DE%C7%F8%B4%F3%C ...

  4. 2016ACM/ICPC亚洲区大连站-重现赛(感谢大连海事大学)(7/10)

    1001题意:n个人,给m对敌对关系,X个好人,Y个坏人.现在问你是否每个人都是要么是好人,要么是坏人. 先看看与X,Y个人有联通的人是否有矛盾,没有矛盾的话咋就继续遍历那些不确定的人关系,随便取一个 ...

  5. HDU 5950 Recursive sequence 【递推+矩阵快速幂】 (2016ACM/ICPC亚洲区沈阳站)

    Recursive sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

  6. HDU 5952 Counting Cliques 【DFS+剪枝】 (2016ACM/ICPC亚洲区沈阳站)

    Counting Cliques Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  7. HDU 5948 Thickest Burger 【模拟】 (2016ACM/ICPC亚洲区沈阳站)

    Thickest Burger Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  8. HDU 5949 Relative atomic mass 【模拟】 (2016ACM/ICPC亚洲区沈阳站)

    Relative atomic mass Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

  9. HDU 6227.Rabbits-规律 (2017ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学))

    Rabbits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total S ...

随机推荐

  1. React初步学习-利用React构建个人博客

    React初步学习-利用React构建个人博客 用React和Webpack写了一个很简单的个人博客,主要是想要熟悉一下react中各种基本基本属性及方法的使用.在构建过程中碰到不少问题,通过阅读官方 ...

  2. 零基础入门学习Python(1)--我和Python的第一次亲密接触

    前言 最近在学习Python编程语言,于是乎就在网上找资源.其中小甲鱼<零基础入门学习Python>试听了几节课,感觉还挺不错,里面的视频都是免费下载,小甲鱼讲话也挺幽默风趣的,所以呢,就 ...

  3. ceph集群

    ceph集群部署 ceph理解: Ceph是一个分布式存储,可以提供对象存储.块存储和文件存储,其中对象存储和块存储可以很好地和各大云平台集成.其他具体介绍可见官网简介:http://docs.cep ...

  4. buf.entries()详解

    buf.entries() 返回:{Iterator} 从当前 Buffer 的内容中,创建并返回一个 [index, byte] 形式的迭代器. const buf = Buffer.from('b ...

  5. LeetCode(53) Maximum Subarray

    题目 Find the contiguous subarray within an array (containing at least one number) which has the large ...

  6. Huawei-R&S-网络工程师实验笔记20190615-IP基础(AR201上配置IP)

    >Huawei-R&S-网络工程师实验笔记20190615-IP基础(AR201上配置IP) >>实验开始,先上拓扑图参考: >>>一般正常配置IP操作如下 ...

  7. POJ1013称硬币【枚举】

    Counterfeit Dollar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 52474   Accepted: 16 ...

  8. C语言不容易识别的坑

    1.重复两次定义 #include<stdio.h> #include<stdlib.h> #include<string.h> int a,b; void fun ...

  9. android listVIew实现button按钮监听程序

    1.重写simpleAdapter 方法@Override public HashMap<String,String> getItem(int position) { // TODO Au ...

  10. linux 常见名词及命令(五)

    计划任务服务之一次性任务: at <时间> 安排一次性任务 atq 或at -l 查看任务列表 at -c 序号 预览任务与设置环境 atrm 序号 删除任务 安排任务示例: 在23:30 ...