HDU 4344-Mark the Rope-大数素因子分解

注意只有一个素因子的情况。

 #include <cstdio>
#include <algorithm>
#include <cstring> using namespace std; typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 4e3+;
struct cake
{
int w,l;
cake(){}
bool operator < (const cake &b) const
{
return l > b.l;
}
}ck[maxn]; int N,len[maxn]; int main()
{
scanf("%d",&N); for(int i=;i<N;i++)
{
scanf("%d%d",&ck[i].w,&ck[i].l);
if(ck[i].w > ck[i].l) swap(ck[i].w,ck[i].l);
} sort(ck,ck+N); int m;
int answ,ansl;
ll ans = -INF; for(int i=;i<N;i++)
{
m = ;
for(int j=;j<N;j++)
{
if(ck[j].w >= ck[i].w)
{
len[m++] = ck[j].l;
}
}
for(int j=;j<m;j++)
{
ll res = (ll)ck[i].w*len[j]*(j+);
if(res > ans)
{
ans = res;
answ = ck[i].w;
ansl = len[j];
}
}
}
printf("%I64d\n%d %d\n",ans,answ,ansl); }
上一篇:【Mybatis框架】查询缓存(二级缓存)


下一篇:EXTJS4.2 控件之Grid getRowClass 添加行背景色