• <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 田兵 閱讀(177) 評論(0)  編輯 收藏 引用 所屬分類: USACO

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

            導航

            統計

            常用鏈接

            留言簿(2)

            隨筆分類(65)

            隨筆檔案(65)

            文章檔案(2)

            ACM

            搜索

            積分與排名

            最新隨筆

            最新評論

            閱讀排行榜

            一级做a爱片久久毛片| 国产成人精品白浆久久69| 国产精品毛片久久久久久久| 狠狠干狠狠久久| 狠狠精品干练久久久无码中文字幕 | 久久国产综合精品五月天| 亚洲欧洲精品成人久久奇米网| 欧美一区二区三区久久综| 成人亚洲欧美久久久久| 久久99精品久久久久久久久久| 国产精品久久自在自线观看| 亚洲国产精品综合久久网络| 大伊人青草狠狠久久| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 国产精品日韩欧美久久综合| 99久久精品国产一区二区| 伊人久久免费视频| 久久亚洲AV成人无码国产| 久久国产乱子伦精品免费午夜| 亚洲精品乱码久久久久久蜜桃图片 | 久久精品aⅴ无码中文字字幕重口| 久久人人爽人人爽人人片AV麻豆| 国产精品99精品久久免费| 无码乱码观看精品久久| 欧美粉嫩小泬久久久久久久| 国产精品久久久久aaaa| 色88久久久久高潮综合影院| 久久人人爽人人爽人人片AV东京热| 久久免费视频6| AA级片免费看视频久久| 狠狠色丁香久久综合五月| 久久精品中文无码资源站| 伊人久久大香线焦AV综合影院| 久久综合色老色| 99久久无色码中文字幕人妻| 亚洲AV伊人久久青青草原| 久久久久亚洲AV无码专区桃色| 成人精品一区二区久久| 久久久久婷婷| 欧美日韩久久中文字幕| 久久国产精品-久久精品|