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

            數(shù)據(jù)范圍小,直接做就可以了

            /*
            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 田兵 閱讀(183) 評(píng)論(0)  編輯 收藏 引用 所屬分類: USACO

            <2010年5月>
            2526272829301
            2345678
            9101112131415
            16171819202122
            23242526272829
            303112345

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(2)

            隨筆分類(65)

            隨筆檔案(65)

            文章檔案(2)

            ACM

            搜索

            積分與排名

            最新隨筆

            最新評(píng)論

            閱讀排行榜

            韩国免费A级毛片久久| 成人a毛片久久免费播放| 热99RE久久精品这里都是精品免费| 人人狠狠综合久久88成人| 四虎国产精品免费久久久| 一本久道久久综合狠狠躁AV| 色婷婷综合久久久久中文一区二区 | 性欧美大战久久久久久久| 久久人人爽人人爽人人AV东京热| 亚洲精品乱码久久久久久蜜桃图片 | 久久久久久久波多野结衣高潮 | 伊人色综合久久| 狠狠色丁香久久婷婷综| 久久精品亚洲AV久久久无码| 国产91久久精品一区二区| 老色鬼久久亚洲AV综合| 欧美伊人久久大香线蕉综合69| 成人免费网站久久久| 久久久久亚洲精品日久生情| 99久久国产综合精品五月天喷水| 久久无码人妻一区二区三区午夜| 亚洲国产精品久久久久| 欧美va久久久噜噜噜久久| 久久影院亚洲一区| 久久久久久亚洲精品影院| 2021国内久久精品| 无码精品久久一区二区三区 | 国产亚洲美女精品久久久久狼| 日本久久中文字幕| 国内精品久久久久伊人av| 亚洲αv久久久噜噜噜噜噜| 日韩欧美亚洲综合久久| 久久精品国产2020| 亚洲欧洲日产国码无码久久99| 性做久久久久久久| 午夜精品久久久久久影视riav| 国产欧美久久久精品影院| 欧美亚洲国产精品久久| 亚洲国产精品久久久天堂| 久久久久亚洲Av无码专| 9999国产精品欧美久久久久久|