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

            閱讀排行榜

            久久久久精品国产亚洲AV无码| 男女久久久国产一区二区三区| 亚洲国产精品热久久| 久久精品中文字幕第23页| 久久99热这里只频精品6| 久久久青草久久久青草| 久久综合精品国产二区无码| 久久婷婷国产麻豆91天堂| 少妇熟女久久综合网色欲| 青青草国产成人久久91网| 久久精品视频一| 亚洲国产成人久久综合区| 国产农村妇女毛片精品久久| 久久99热精品| 国产精品天天影视久久综合网| 国内精品久久久久久久久电影网| 亚洲日本久久久午夜精品| 久久国产成人精品麻豆| 免费精品久久天干天干| 久久婷婷五月综合色99啪ak| 久久不见久久见免费影院www日本| 久久电影网2021| 久久天天躁狠狠躁夜夜avapp| 日韩中文久久| 午夜精品久久久久久毛片| 久久久噜噜噜久久中文福利| 国产成人久久精品区一区二区| 国产亚洲精品久久久久秋霞| 久久天天躁狠狠躁夜夜躁2014| 性做久久久久久久久| 亚洲Av无码国产情品久久| 久久久久亚洲AV成人网| 伊人热人久久中文字幕| 99精品久久精品一区二区| 国产精品久久久亚洲| 模特私拍国产精品久久| 日日狠狠久久偷偷色综合0| 亚洲欧洲精品成人久久曰影片 | 久久免费看黄a级毛片| 亚洲欧美另类日本久久国产真实乱对白 | 国产三级观看久久|