• <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>

            USACO chapter 2 section 2.1 Ordered Fractions

            USER: tianbing tianbing [tbbd4261]
            TASK: frac1
            LANG: C++
            Compiling...
            Compile: OK
            Executing...
            Test 1: TEST OK [0.000 secs, 2928 KB]
            Test 2: TEST OK [0.000 secs, 2928 KB]
            Test 3: TEST OK [0.000 secs, 2928 KB]
            Test 4: TEST OK [0.011 secs, 2928 KB]
            Test 5: TEST OK [0.011 secs, 2928 KB]
            Test 6: TEST OK [0.000 secs, 2928 KB]
            Test 7: TEST OK [0.011 secs, 2928 KB]
            Test 8: TEST OK [0.054 secs, 2928 KB]
            Test 9: TEST OK [0.043 secs, 2928 KB]
            Test 10: TEST OK [0.108 secs, 2928 KB]
            Test 11: TEST OK [0.313 secs, 2928 KB]
            All tests OK.
            

            YOUR PROGRAM ('frac1') WORKED FIRST TIME! That's fantastic -- and a rare thing. Please accept these special automated congratulations.

            Here are the test data inputs:

            ------- test 1 -------
            1
            ------- test 2 -------
            2
            ------- test 3 -------
            4
            ------- test 4 -------
            7
            ------- test 5 -------
            10
            ------- test 6 -------
            15
            ------- test 7 -------
            24
            ------- test 8 -------
            50
            ------- test 9 -------
            75
            ------- test 10 -------
            100
            ------- test 11 -------
            160
            
            Keep up the good work!
            
            Thanks for your submission!

            數據范圍小,直接做就可以了

            /*
            ID:tbbd4261
            PROG:frac1
            LANG:C++
            */
            #include
            <iostream>
            #include
            <vector>
            #include
            <algorithm>
            #include
            <fstream>
            using namespace std;
            ifstream fin(
            "frac1.in");
            ofstream fout(
            "frac1.out");
            typedef 
            struct 
            {
              
            int x,y;
            } type;

            vector
            <type>vec;

            int gcd(int x, int y)
            {
                
            if(!x||!y)return x>y?x:y;
                
            for(int t; t=x%y; x=y,y=t)
                   ;
                
            return y;
            }

            bool f(type a,type b)
            {
                 
            return a.x*1.0/a.y<b.x*1.0/b.y;
            }

            void solve (int n)
            {
                 type tem;
                 
            int a=0,b=1;
                 
            for(b=1; b<=n; b++)
                 
            for(a=0; a<=b; a++)
                 {
                    
            if(gcd(a,b)==1)
                    {
                      tem.x
            =a; tem.y=b;
                      vec.push_back(tem);
                      }
                 }
                 sort(vec.begin(),vec.end(),f);
                 
            for(int i=0; i<vec.size(); i++)
                 fout
            <<vec[i].x<<"/"<<vec[i].y<<endl;
            }

            int main()
            {
              
                
                
            int n;
                fin
            >>n;
                solve(n);
               
            // system("pause");
                return 0;
            }

            posted on 2010-06-18 10:52 田兵 閱讀(176) 評論(0)  編輯 收藏 引用 所屬分類: USACO

            <2010年6月>
            303112345
            6789101112
            13141516171819
            20212223242526
            27282930123
            45678910

            導航

            統計

            常用鏈接

            留言簿(2)

            隨筆分類(65)

            隨筆檔案(65)

            文章檔案(2)

            ACM

            搜索

            積分與排名

            最新隨筆

            最新評論

            閱讀排行榜

            久久电影网2021| 色婷婷综合久久久中文字幕| 99久久精品免费看国产| 麻豆久久| 久久久久久人妻无码| 久久久噜噜噜久久| 亚洲精品国产美女久久久| 久久青青草原国产精品免费| 亚洲国产成人精品女人久久久 | 亚洲国产精品无码久久| 国产精品久久自在自线观看| 久久91精品国产91| 26uuu久久五月天| 亚洲国产精品无码久久久秋霞2| 99久久精品无码一区二区毛片| 日本欧美久久久久免费播放网| 久久精品国产亚洲Aⅴ香蕉| 精品久久久久久久无码| 尹人香蕉久久99天天拍| 国产精品免费久久| 国产亚洲精品美女久久久| 香蕉99久久国产综合精品宅男自| 99久久成人国产精品免费| 77777亚洲午夜久久多人| 亚洲AV伊人久久青青草原| 久久久久久久国产免费看| 91精品国产综合久久四虎久久无码一级| 久久人人爽人人爽人人av东京热| 九九久久精品无码专区| 91精品国产高清久久久久久国产嫩草| 97久久精品无码一区二区天美| 久久午夜夜伦鲁鲁片免费无码影视 | 国产成人久久AV免费| 亚洲伊人久久大香线蕉综合图片| 思思久久99热免费精品6| 国产午夜精品理论片久久| 香港aa三级久久三级| 精品久久久久国产免费| 久久久噜噜噜久久| 亚洲色欲久久久久综合网| 久久精品一区二区三区AV|