• SCAU 10690 分面包


    10690 分面包

    时间限制:1000MS  内存限制:65535K

    题型: 编程题   语言: 无限制

    Description

    在大一的时候,XCC还在stu union打酱油~~~~和十三还有奶子他们去外面吃吃喝喝是常有的事。
    大家都知道空腹喝酒是有害肚子滴,所以呢,要买一些面包来下酒。不过我们有个习惯,
    就是所有的n个人,每个人分得的面包必须长度相等(长度相等的面包的量是一样的),
    同时捏~给每个人分面包时,分得的小面包必须是来自同一块面包的,即不能把两个不同面包各切一部分下来凑合成一份面包来分。
    现在一起来的有n个人,买了m个面包,求每人分得的最长面包长度。

    输入格式

    第一行是人数 n 和面包数目 m (3<= n <= 16 , 1 <= m <= 100),第二行 m 个数字表示 m 个面包的长度 L ,均为整数( 1 <= L <= 1000000)

    输出格式

    每人分得的最长面包长度,保留2位小数

    输入样例

    3  3
    3  3  3

    输出样例

    3.00

    提示

    注意题目描述

    //scau_Joseph 注:每个人只能有一条面包,而一条面包可以分给若干个人,所以一个人手中的面包可以是不完整的(即被切过),最终每个人的面包是相同长度,剩余的不管

    来源

    scau_acm 

    作者

    scau_acm

     1 #include<iostream>
     2 #include<cstring>
     3 #include<cstdio>
     4 #include<cmath>
     5 #include<algorithm>
     6 
     7 using namespace std;
     8 
     9 int store[102];
    10 
    11 int main()
    12 {
    13 //    freopen("input.txt", "r", stdin);
    14     int n, m, cnt = 0, len;
    15     double res = 0;
    16     scanf("%d%d", &n, &m);
    17     memset(store, 0, sizeof(store));
    18     for(int i=0; i<m; ++i)
    19     {
    20         scanf("%d", &len);
    21         store[cnt++] = len;
    22     }
    23     sort(store, store+cnt);
    24     double mid, maxn = store[cnt-1], minn = 0;
    25     int sum = 0, flag = 0;
    26     mid = (minn + maxn)/2;
    27     while(maxn - minn > 0.000001)
    28     {
    29         mid = (minn + maxn)/2;
    30         sum = 0;
    31         for(int i=cnt-1; i>=0; --i)
    32         {
    33             int temp = (int)floor(1.0*store[i]/mid);
    34             sum += temp;
    35             if(sum >= n || store[i] < mid) break;
    36         }
    37         if(sum >=n) minn = mid;
    38         else maxn = mid;
    39     }
    40     printf("%.2lf
    ", mid);
    41 
    42     return 0;
    43 }
  • 相关阅读:
    ZZZZ
    linux expect, spawn用法小记
    小议common lisp程序开发流程
    解决编译apache出现的问题:configure: error: APR not found . Please read the documentation
    SMART原则_百度百科
    心态不够青春,所以身上的技术也容易衰老
    What is tradebit?
    About VirtualBoxImages.com
    ssh-copy-id -i ~/.ssh/id_rsa.pub admin@172.17.42.66
    香港mtmit真皮休闲商务双用时尚浮点手拿包1018 烟灰色-大号 均码【图片 价格 品牌 报价】-京东商城
  • 原文地址:https://www.cnblogs.com/liaoguifa/p/3188991.html
Copyright © 2020-2023  润新知