zoukankan      html  css  js  c++  java
  • hdu 2335 Containers

    水题,就不解释了,不过这个题有一点很好,就是枚举的时候,枚举宽,也就是列数,因为这样才能越来越接近正方形

     1 #include<cstdio>
     2 #include<cstring>
     3 #include<iostream>
     4 #include<algorithm>
     5 #include<cmath>
     6 #include<string>
     7 #include<queue>
     8 #include<stack>
     9 #include<map>
    10 #include<vector>
    11 #define maxn 5000
    12 #define MAXN 2005
    13 #define MAXM 20000005
    14 #define INF  100000000000000
    15 #define oo 1000000007
    16 using namespace  std;
    17 
    18 typedef long long LL;
    19 int main()
    20 {
    21     int t;
    22     while(scanf("%d",&t)!=EOF)
    23     {
    24         while(t--)
    25         {
    26             LL n,x,y;
    27             LL min_n=INF;
    28             scanf("%I64d",&n);
    29             n=(n+4)/5;
    30             LL tem=(LL)sqrt(double(n));
    31             for(LL i=1; i<=tem; i++)
    32             {
    33                 LL j=(n+(i-1))/i;
    34                 LL xx=i*40+(i+1)*4;
    35                 LL yy=j*8+(j+1)*2;
    36                 //printf("%I64d %I64d %I64d %I64d
    ",i,j,xx,yy);
    37                 if(xx*yy<min_n)
    38                 {
    39                     x=xx;
    40                     y=yy;
    41                     min_n=xx*yy;
    42                 }
    43                 else if(xx*yy==min_n)
    44                 {
    45                     if(abs(x-y)>abs(xx-yy))
    46                     {
    47                         x=xx;
    48                         y=yy;
    49                     }
    50                 }
    51             }
    52             printf("%I64d X %I64d = %I64d
    ",max(x,y),min(x,y),min_n);
    53 
    54         }
    55     }
    56     return 0;
    57 }
  • 相关阅读:
    cross-domain
    【转】React、Vue访问NotFound
    Flutter环境配置
    antd遇见的坑
    npm源设置
    React中的生命周期函数
    【备忘】javascript原型、Function、eval、闭包、json处理、类、arguments不定
    ADB获取手机信息
    selenium操作
    操作execl
  • 原文地址:https://www.cnblogs.com/tsw123/p/4399230.html
Copyright © 2011-2022 走看看