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

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

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(2)

            隨筆分類(lèi)(65)

            隨筆檔案(65)

            文章檔案(2)

            ACM

            搜索

            積分與排名

            最新隨筆

            最新評(píng)論

            閱讀排行榜

            91精品国产色综久久| 久久香蕉国产线看观看精品yw| 中文成人无码精品久久久不卡 | 老色鬼久久亚洲AV综合| 久久精品国产精品亚洲| 99久久精品国产综合一区| 久久天天躁狠狠躁夜夜不卡| 99久久99久久精品国产| 久久久久99精品成人片试看| 久久婷婷国产剧情内射白浆 | 91精品日韩人妻无码久久不卡| 少妇久久久久久久久久| 美女写真久久影院| 久久精品国产亚洲αv忘忧草| 亚洲精品国产美女久久久| 99久久99久久久精品齐齐| 久久国产精品成人影院| 99久久精品国产高清一区二区| 亚洲国产精品18久久久久久| 三级三级久久三级久久| 久久午夜伦鲁片免费无码| 久久婷婷五月综合97色| 久久97精品久久久久久久不卡| 国内精品免费久久影院| 久久久国产视频| 国产日韩欧美久久| 亚洲国产另类久久久精品黑人 | 99久久婷婷国产综合亚洲| 品成人欧美大片久久国产欧美...| 国产成人综合久久精品尤物| 伊人色综合九久久天天蜜桃| 香蕉久久夜色精品升级完成| 亚洲国产精品久久66| 久久综合亚洲色HEZYO社区| 久久综合丁香激情久久| 中文字幕热久久久久久久| 女人香蕉久久**毛片精品| 久久久精品2019免费观看| 无码乱码观看精品久久| 久久AAAA片一区二区| 国产精品免费久久久久电影网|