zoukankan      html  css  js  c++  java
  • HDU 4344-Mark the Rope-大数素因子分解

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

     1 #include <cstdio>
     2 #include <algorithm>
     3 #include <cstring>
     4 
     5 using namespace std;
     6 
     7 typedef long long ll;
     8 const int INF = 0x3f3f3f3f;
     9 const int maxn = 4e3+10;
    10 struct cake
    11 {
    12     int w,l;
    13     cake(){}
    14     bool operator < (const cake &b) const
    15     {
    16         return l > b.l;
    17     }
    18 }ck[maxn];
    19 
    20 int N,len[maxn];
    21 
    22 int main()
    23 {
    24     scanf("%d",&N);
    25 
    26     for(int i=0;i<N;i++)
    27     {
    28         scanf("%d%d",&ck[i].w,&ck[i].l);
    29         if(ck[i].w > ck[i].l) swap(ck[i].w,ck[i].l);
    30     }
    31 
    32     sort(ck,ck+N);
    33 
    34     int m;
    35     int answ,ansl;
    36     ll ans = -INF;
    37 
    38     for(int i=0;i<N;i++)
    39     {
    40         m = 0;
    41         for(int j=0;j<N;j++)
    42         {
    43             if(ck[j].w >= ck[i].w)
    44             {
    45                 len[m++] = ck[j].l;
    46             }
    47         }
    48         for(int j=0;j<m;j++)
    49         {
    50             ll res = (ll)ck[i].w*len[j]*(j+1);
    51             if(res > ans)
    52             {
    53                 ans = res;
    54                 answ = ck[i].w;
    55                 ansl = len[j];
    56             }
    57         }
    58     }
    59     printf("%I64d
    %d %d
    ",ans,answ,ansl);
    60 
    61 }
  • 相关阅读:
    swoole 的 go function 是什么
    MySQL grant之后要不要跟上 flush privileges
    操作数据库
    APP端异常情况
    评论列表优化联表问题
    tp5修改数据前过滤
    字典
    if语句
    【整理】android事件传递机制
    Linux常用操作
  • 原文地址:https://www.cnblogs.com/helica/p/5229319.html
Copyright © 2011-2022 走看看