• <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>
            付翔的專欄
            在鄙視中成長 記錄成長的點滴
            posts - 106,  comments - 32,  trackbacks - 0
            水題,枚舉 ,只是我在判重的時候用 set<double> 這個在usaco 得出的結果和 本地vs 運行的結果不同。最后改用gcd 判斷 分子除以分母是否可約。 

            /*
            ID:fuxiang2
            PROG: frac1
            LANG: C++
            */
            #include <iostream>
            #include <fstream>
            #include <stack>
            #include <string>
            #include <vector>
            #include <queue>
            #include <map>
            #include <list>
            #include <algorithm>
            #include <set>
            #include <cmath>
            #include <cstring>
            #include <cstdlib>
             
            #define REP(i, n) for (int i=0;i<int(n);++i)
            #define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
            #define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
            #define REP_1(i, n) for (int i=1;i<=int(n);++i)
            #define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)
            #define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)
            #define EACH(it, A) for (typeof(A.begin()) it=A.begin(); it != A.end(); ++it)
             
            using namespace std;
            ofstream fout ("frac1.out");
            ifstream fin ("frac1.in");
             
            class Node{
            public
                int a;//分子
                int b;// 分母
                double val;
                Node() {}
                Node(int _a,int _b ,double _val) :a(_a),b(_b),val(_val){}
             
                bool operator < (const Node & m)const {
                    return val < m.val; 
                }
            };
            set<double> sd;
            vector<Node> vn;
            int gcd(int a,int b)
            {
                if(b == 1)
                    return b;
                if(b == 0)
                    return a;
                return gcd(b,a%b);
            }
            void worik(int n)
            {
                double ans ;
                FOR_1(i,1,n)
                    FOR_1(j,1,n){
                        if(i < j)
                        {
                            ans = i*1.0/j;
                            //if(sd.find(ans) == sd.end())
                            if(gcd(j,i) == 1)
                            {
                                Node  node(i,j,ans);
                                vn.push_back(node);
                                sd.insert(ans);
                            }
                        }
                    }
                 
                sort(vn.begin() ,vn.end());
             
                fout<< "0/1" << endl;
                for(vector <Node> ::iterator iter = vn.begin() ; iter != vn.end() ; iter ++){
                    fout << (iter)->a << "/" << (iter)->b <<endl;
                }
                fout<<"1/1"<<endl;
             
            }
             
            int main()
            {
                int n;
                fin>>n;
                worik(n);
                return 0;
             
            }


            原始博客地址: http://www.fuxiang90.com/2012/07/usaco2-1-ordered-fractions/
            posted on 2012-07-18 09:54 付翔 閱讀(308) 評論(0)  編輯 收藏 引用 所屬分類: ACM 數據結構

            <2012年7月>
            24252627282930
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(2)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            CSDN - 我的blog地址

            博客

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            一本色道久久综合亚洲精品| 亚洲国产成人久久精品99 | 久久久无码精品午夜| 久久久久免费视频| 免费久久人人爽人人爽av| 久久这里只有精品18| 狠狠人妻久久久久久综合| 精品人妻伦九区久久AAA片69| 久久精品亚洲精品国产色婷| 久久精品成人国产午夜| 久久亚洲精品无码aⅴ大香| 久久综合九色综合97_久久久| 久久亚洲精品无码观看不卡| 久久久久国产精品熟女影院| 亚洲欧美日韩精品久久亚洲区| 1000部精品久久久久久久久| 亚洲精品午夜国产va久久| 99国内精品久久久久久久| 精品少妇人妻av无码久久| 久久受www免费人成_看片中文| 亚洲欧美精品伊人久久| 精品国际久久久久999波多野| 日本WV一本一道久久香蕉| 久久精品国产色蜜蜜麻豆 | 久久精品亚洲福利| 久久综合九色综合97_久久久| 久久久久亚洲av无码专区喷水| 香蕉久久夜色精品国产2020 | 99久久国产亚洲高清观看2024| 亚洲国产精品久久久天堂| 2021国产精品久久精品| 亚洲欧美另类日本久久国产真实乱对白| 久久成人国产精品二三区| …久久精品99久久香蕉国产| 久久久久亚洲AV成人片| 久久丫精品国产亚洲av| www久久久天天com| 久久九九亚洲精品| 色综合久久综精品| 久久夜色精品国产亚洲av| 欧美亚洲另类久久综合婷婷|