• <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>
            心如止水
            Je n'ai pas le temps
            posts - 400,comments - 130,trackbacks - 0
            可以寫出方程ax+by=n,對于該題來說,首先有x>=0, y>=0;其次x要么盡量大,要么盡量小。
            以下是我的代碼:
            #include <iostream>
            #include 
            <cstdio>
            #include 
            <cmath>
            using namespace std;
            typedef 
            long long int64;

            int64 Gcd ( int64 a, int64 b )
            {
                
            for ( int64 t = a % b; t; a = b, b = t, t = a % b ); return b;
            }

            void ExpandGcd ( int64 a, int64 b, int64 &d, int64 &x, int64 &y )
            {
                
            if ( b ) { ExpandGcd ( b, a % b, d, y, x ); y -= a / b * x; }
                
            else { d = a; x = 1; y = 0; }
            }

            int main ( )
            {
            #ifndef ONLINE_JUDGE
                freopen ( 
            "data.in""r", stdin );
            #endif
                
                int64 n, n1, n2, c1, c2;
                int64 d, x0, y0, x1, y1, x2, y2, ansx, ansy;
                
            while ( cin >> n && n )
                {
                    cin 
            >> c1 >> n1 >> c2 >> n2;
                    
            //  Input
                    
                    d 
            = Gcd ( n1, n2 );
                    
            if ( n % d )
                    {
                        printf ( 
            "failed\n" );
                        
            continue;
                    }
                    
                    n 
            /= d; n1 /= d; n2 /= d;
                    ExpandGcd ( n1, n2, d, x0, y0 );
                    x0 
            *= n;
                    y0 
            *= n;
                    
                    int64 a 
            = (int64)ceil ( -(double)x0 / n2 ), b = (int64)floor ( (double)y0 / n1 );
                    
                    
            if ( a > b )
                    {
                        printf ( 
            "failed\n" );
                        
            continue;
                    }
                    
                    x1 
            = x0 + n2 * a;
                    y1 
            = y0 - n1 * a;
                    x2 
            = x0 + n2 * b;
                    y2 
            = y0 - n1 * b;
                    
                    
            if ( x1 * c1 + y1 * c2 < x2 * c1 + y2 * c2)
                    {
                        ansx 
            = x1;
                        ansy 
            = y1;
                    }
                    
            else
                    {
                        ansx 
            = x2;
                        ansy 
            = y2;
                    }
                    
            //  Solve
                    
                    cout 
            << ansx << " " << ansy <<endl;
                    
            //  Output
                }
                
                
            return 0;
            }
            posted on 2011-09-06 18:34 lee1r 閱讀(638) 評論(0)  編輯 收藏 引用 所屬分類: 題目分類:數學/數論
            久久婷婷五月综合色奶水99啪| 精品国产乱码久久久久久呢| 久久久国产精品福利免费| 久久综合九色综合网站| 99久久er这里只有精品18| 久久免费视频观看| 久久综合色老色| 久久国产精品-久久精品| 青青草原综合久久大伊人导航| 亚洲欧美成人久久综合中文网| 欧美精品久久久久久久自慰| 久久精品成人| 久久99免费视频| 国内精品久久久久影院薰衣草 | 久久不见久久见免费影院www日本| 久久久WWW成人免费毛片| 久久久无码精品亚洲日韩蜜臀浪潮 | 久久精品青青草原伊人| 久久精品国产亚洲一区二区| 国产精品久久久久久久久软件 | 久久影院综合精品| 亚洲国产小视频精品久久久三级 | 丰满少妇人妻久久久久久| 亚洲欧美成人久久综合中文网| 久久er热视频在这里精品| 伊人久久大香线焦AV综合影院| 久久夜色精品国产亚洲av| 久久精品中文字幕久久| 精品人妻久久久久久888| 久久久久亚洲AV无码专区首JN | 天天爽天天爽天天片a久久网| 日韩精品久久久久久免费| 伊人久久成人成综合网222| 久久精品女人天堂AV麻| 精品视频久久久久| 久久久久九九精品影院| 久久久久久极精品久久久| 久久久久亚洲AV成人网| 久久人人爽人人精品视频| 一级女性全黄久久生活片免费| 青青草原综合久久大伊人导航|