• <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>
            付翔的專欄
            在鄙視中成長(zhǎng) 記錄成長(zhǎng)的點(diǎn)滴
            posts - 106,  comments - 32,  trackbacks - 0
            分析后 和之前的類似,每一步有六種狀態(tài)轉(zhuǎn)移的方式 : c->a ;c->b; a->c;b->c,a->b ;b->a
            那每個(gè)狀態(tài)是 a,b,c 的牛奶數(shù)量,因?yàn)槭鞘菑? -20 ,那么等于是有20^3種狀態(tài)、

            和之前的clock 很像,標(biāo)記狀態(tài)hash 判重,遍歷所有的情況就可以。

             1 /*
             2 ID:fuxiang2
             3 PROG: ariprog
             4 LANG: C++
             5 */
             6 #include <iostream>
             7 #include <fstream>
             8 #include <string>
             9 #include <vector>
            10 #include <map>
            11 #include <algorithm>
            12 #include <set>
            13 #include <cmath>
            14  
            15 #define REP(i, n) for (int i=0;i<int(n);++i)
            16 #define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
            17 #define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
            18 #define REP_1(i, n) for (int i=1;i<=int(n);++i)
            19 #define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)
            20 #define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)
            21  
            22 using namespace std;
            23 ofstream fout ("ariprog.out");
            24 ifstream fin ("ariprog.in");
            25  
            26 int n,m;
            27 //set<int> si;
            28  
            29 int hash[62510 * 2];
            30  
            31 class node
            32 {
            33 public:
            34     int a;
            35     int b;
            36  
            37     node(int _a, int _b){
            38         a = _a;
            39         b = _b;
            40     }
            41     bool operator < (const node & m )const {
            42         if(m.b == b) return a < m.a;
            43         return b < m.b;
            44     }
            45 };
            46 vector<node> vn;
            47  
            48 //應(yīng)該是這里比較費(fèi)時(shí)間
            49 void work(int a,int b)
            50 {
            51     int ans = a;
            52     if(hash[ans]  == 0)
            53         return ;
            54     FOR(i,0,n-1){
            55         ans += b;
            56         if(hash[ans] == 0)
            57             return ;
            58     }
            59     node t(a,b);
            60     vn.push_back(t);
            61  
            62 }
            63 int main()
            64 {
            65     fin >> n >> m;
            66     FOR_1(i,0,m)
            67         FOR_1(j,0,m){
            68             int ii = i*i;
            69             int jj = j*j;
            70             hash[ii + jj] = 1;
            71         }
            72     int end = m*m ;
            73     FOR_1(i,0,end)
            74         FOR_1(j,1,end){
            75             if(  (i + (n-1)*j) <= 2*end)
            76                 work(i,j);
            77             else
            78                 break;
            79     }
            80     sort(vn.begin(),vn.end());
            81     if(vn.empty())
            82         fout << "NONE"<<endl;
            83     else
            84         for(vector<node>::iterator  iter =  vn.begin() ; iter != vn.end() ; iter ++ ){
            85             fout << iter->a << " "<< iter ->b<<endl;
            86         }
            87  
            88         return 0;
            89 }

            原始博客地址:http://www.fuxiang90.com/2012/06/usaco1-4-mothers-milk/

             

            posted on 2012-07-10 10:39 付翔 閱讀(347) 評(píng)論(0)  編輯 收藏 引用 所屬分類: ACM 數(shù)據(jù)結(jié)構(gòu)

            <2010年8月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(2)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            CSDN - 我的blog地址

            博客

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            亚洲狠狠久久综合一区77777| 久久高潮一级毛片免费| 青青草原精品99久久精品66| 看久久久久久a级毛片| 国产AV影片久久久久久| 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 亚洲AV无码久久精品色欲 | yellow中文字幕久久网| 亚洲国产高清精品线久久| 久久精品国产亚洲77777| 久久久久久国产精品免费免费| 亚洲日韩中文无码久久| 国产精品嫩草影院久久| 蜜臀久久99精品久久久久久小说| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 久久久久女人精品毛片| 久久免费国产精品| 996久久国产精品线观看| 热久久视久久精品18| 久久se精品一区精品二区国产| 久久Av无码精品人妻系列| 18禁黄久久久AAA片| 久久久久无码中| 精品国产综合区久久久久久| 国产精品一区二区久久精品| 久久亚洲精品无码AV红樱桃| 久久久久久久波多野结衣高潮 | 亚洲中文字幕久久精品无码APP| 久久久国产精华液| 久久精品国产精品亚洲| 国产午夜精品久久久久九九电影| 99热成人精品热久久669| 久久亚洲春色中文字幕久久久| 亚洲国产精品一区二区久久hs| 久久综合鬼色88久久精品综合自在自线噜噜 | 久久99国产精品尤物| 国产69精品久久久久久人妻精品| 中文精品久久久久人妻| 久久久中文字幕日本| 狠狠色丁香久久婷婷综合_中| 午夜精品久久久久|