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

            閱讀排行榜

            97热久久免费频精品99| 亚洲AV无码1区2区久久| 欧美日韩精品久久久久| 中文成人无码精品久久久不卡 | 久久人做人爽一区二区三区| 亚洲欧洲久久久精品| 久久精品国产亚洲AV不卡| 久久99久久99精品免视看动漫| 国产成人99久久亚洲综合精品| 久久er热视频在这里精品| 国产—久久香蕉国产线看观看| 亚洲欧美一级久久精品| 精品久久久久久无码中文野结衣| AV无码久久久久不卡蜜桃| 国产免费久久久久久无码| 日产精品99久久久久久| 伊人久久大香线蕉成人| 国产国产成人久久精品| 狠狠色丁香久久婷婷综| 久久久久无码精品国产不卡| 亚洲欧洲久久久精品| 久久免费视频一区| 国产AⅤ精品一区二区三区久久| 欧美一区二区三区久久综| 久久精品免费一区二区| 亚洲综合久久夜AV | 婷婷久久综合九色综合绿巨人| 久久九九久精品国产| 亚洲天堂久久精品| 99久久精品国产综合一区| 国产亚洲欧美成人久久片| 国产精品久久久久久久| 久久精品国产亚洲AV香蕉| 久久精品国产亚洲AV无码娇色| 精品国产乱码久久久久久1区2区| 久久精品亚洲AV久久久无码| 性做久久久久久久| 99精品国产在热久久| 久久综合综合久久狠狠狠97色88| 亚洲天堂久久精品| 亚洲精品97久久中文字幕无码|