• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            ACM___________________________

            ______________白白の屋
            posts - 182, comments - 102, trackbacks - 0, articles - 0
            <2010年8月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(24)

            隨筆分類(332)

            隨筆檔案(182)

            FRIENDS

            搜索

            積分與排名

            最新隨筆

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            HDOJ 1070 HDU 1070 Milk ACM 1070 IN HDU

            Posted on 2010-09-18 11:29 MiYu 閱讀(1876) 評(píng)論(2)  編輯 收藏 引用 所屬分類: ACM ( 水題 )

            MiYu原創(chuàng), 轉(zhuǎn)帖請(qǐng)注明 : 轉(zhuǎn)載自 ______________白白の屋    

             

            題目地址:

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

            題目描述:

            Milk

            Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
            Total Submission(s): 4483    Accepted Submission(s): 983


            Problem Description
            Ignatius drinks milk everyday, now he is in the supermarket and he wants to choose a bottle of milk. There are many kinds of milk in the supermarket, so Ignatius wants to know which kind of milk is the cheapest.

            Here are some rules:
            1. Ignatius will never drink the milk which is produced 6 days ago or earlier. That means if the milk is produced 2005-1-1, Ignatius will never drink this bottle after 2005-1-6(inclusive).
            2. Ignatius drinks 200mL milk everyday.
            3. If the milk left in the bottle is less than 200mL, Ignatius will throw it away.
            4. All the milk in the supermarket is just produced today.

            Note that Ignatius only wants to buy one bottle of milk, so if the volumn of a bottle is smaller than 200mL, you should ignore it.
            Given some information of milk, your task is to tell Ignatius which milk is the cheapest.
             

            Input
            The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
            Each test case starts with a single integer N(1<=N<=100) which is the number of kinds of milk. Then N lines follow, each line contains a string S(the length will at most 100 characters) which indicate the brand of milk, then two integers for the brand: P(Yuan) which is the price of a bottle, V(mL) which is the volume of a bottle.
             

            Output
            For each test case, you should output the brand of the milk which is the cheapest. If there are more than one cheapest brand, you should output the one which has the largest volume.
             

            Sample Input
            2 2 Yili 10 500 Mengniu 20 1000 4 Yili 10 500 Mengniu 20 1000 Guangming 1 199 Yanpai 40 10000
             

            Sample Output
            Mengniu Mengniu
            Hint
            In the first case, milk Yili can be drunk for 2 days, it costs 10 Yuan. Milk Mengniu can be drunk for 5 days, it costs 20 Yuan. So Mengniu is the cheapest.In the second case, milk Guangming should be ignored. Milk Yanpai can be drunk for 5 days, but it costs 40 Yuan. So Mengniu is the cheapest.
             

             

            題目分析 :

              SHIT!!!!

              很簡(jiǎn)單的一道水題!!   竟然 讓我 WA 7 次.  日了 .    

              沒(méi)仔細(xì)看清題目啊 ,  以為是水題就大意了..............    注意輸出的 后面有一點(diǎn)  TIP :   

                If there are more than one cheapest brand, you should output the one which has the largest volume.

               其他的就是 算出 平均每天的 花費(fèi) 排個(gè)序就OK了 .  但是這里又 讓我 惡心了 :

                對(duì)DOUBLE 型排序 用  :

                   if ( a.wei - b.wei > 1e-7 )

                    return true;

                  else if ( a.wei - b.wei < 1e-7 )

                    return false;

                  else return a.vol > b.vol;

                竟然是 WA  !!!!!!  硬是改用:

                   if ( a.wei != b.wei )  //  double  這樣比不會(huì)有精度問(wèn)題 ???

                          return a.wei < b.wei;

                      else return a.vol > b.vol; 

                就AC 了 !!! ....做了這么久的題才發(fā)現(xiàn) 原來(lái) DOUBLE  是這樣比的?!?!??!?!?   

                求 解釋.............. 

             

            AC  代碼如下 :

             /*

            Coded By  : MiYu

            Link      : Link      : http://www.cnblogs.com/MiYu  || http://www.shnenglu.com/MiYu

            Author By : MiYu

            Test      : 1

            Program   : 1070

            */

            //#pragma warning( disable:4789 )

            #include <iostream>

            #include <algorithm>

            #include <string>

            #include <set>

            #include <map>

            #include <utility>

            #include <queue>

            #include <stack>

            #include <list>

            #include <vector>

            #include <cstdio>

            #include <cstdlib>

            #include <cstring>

            #include <cmath>

            using namespace std;

            typedef struct milk {

                   char name[110];

                   int pay;

                   int vol; 

                   double wei;    

            }ML;

            ML M;

            bool cmp ( const ML &a, const ML &b ){

                 if ( a.wei != b.wei )

                    return a.wei < b.wei;

                 else return a.vol > b.vol;  

            int main ()

            {

                int T;

                cin >> T; 

                while ( T -- ){

                      int N;

                      vector <ML> vec;

                      cin >> N;

                      for ( int i = 0; i < N; ++ i ){

                           cin >> M.name >> M.pay >> M.vol;

                           int d = 0;

                           int t = M.vol;

                           while ( t >= 200 && d <= 4 ){

                                 d ++;

                                 t -= 200;  

                           }

                           if ( d ) {

                               M.wei = M.pay * 1.0 / d; 

                               vec.push_back ( M );

                           }

                      }       

                      sort ( vec.begin(), vec.end(), cmp );

                      cout << vec[0].name << endl;

                }

                return 0;

            }


             

             

             

            Feedback

            # re: HDOJ 1070 HDU 1070 Milk ACM 1070 IN HDU  回復(fù)  更多評(píng)論   

            2010-09-24 12:19 by Tanky Woo
            代碼這么少,我等會(huì)也去做做。

            # re: HDOJ 1070 HDU 1070 Milk ACM 1070 IN HDU  回復(fù)  更多評(píng)論   

            2010-09-25 20:27 by MiYu
            很水的題, 就是那個(gè) cmp 函數(shù) 害我錯(cuò) 7次, 不知道為什么, 以前一直哪有寫的沒(méi)錯(cuò), 這題就錯(cuò)了 ................double 還能用 != 比較, 0rz............
            一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 亚洲国产成人久久精品动漫| 国产精品久久久久久影院| 久久精品人人做人人爽电影| 婷婷久久综合九色综合九七| 久久久久亚洲av无码专区喷水 | 国产成人精品久久亚洲| 思思久久99热只有频精品66| 久久青青草原亚洲av无码app| 国产成人AV综合久久| 国产偷久久久精品专区| 狠狠人妻久久久久久综合蜜桃| 久久久一本精品99久久精品88| 久久久久国产精品| 久久夜色精品国产噜噜噜亚洲AV | 久久久亚洲裙底偷窥综合| 91麻精品国产91久久久久| 久久综合给合久久国产免费| 久久影视综合亚洲| 办公室久久精品| 久久99精品国产99久久| 无码伊人66久久大杳蕉网站谷歌 | 97精品伊人久久大香线蕉| 国产精品欧美久久久久无广告 | 国产精品一久久香蕉国产线看观看 | 久久综合亚洲色HEZYO社区| 88久久精品无码一区二区毛片 | 久久99精品免费一区二区| 潮喷大喷水系列无码久久精品 | 久久久久亚洲av毛片大| 99久久国产综合精品五月天喷水 | 国产91久久精品一区二区| 久久久婷婷五月亚洲97号色| 狠狠综合久久综合88亚洲| 一本色道久久综合狠狠躁篇 | 久久国产精品国语对白| 久久精品国产一区| 久久精品国产只有精品2020| www亚洲欲色成人久久精品| 国产高清美女一级a毛片久久w| 中文字幕成人精品久久不卡|