• <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>
            隨筆 - 68  文章 - 57  trackbacks - 0
            <2009年6月>
            31123456
            78910111213
            14151617181920
            21222324252627
            2829301234
            567891011

            常用鏈接

            留言簿(8)

            隨筆分類(74)

            隨筆檔案(68)

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            也是很赤裸裸的模型,這里求的是絕對值最小解,還有就是用到高精。我用java不會寫傳引用,因此只好開了全局變量。

            import java.math.*;
            import java.util.*;

            public class Main
            {
              
            static public BigInteger x = null, y = null;
                
              
            static BigInteger extended_gcd(BigInteger a, BigInteger b)
              
            {
                  BigInteger zero 
            = new BigInteger(new String("0"));
                  BigInteger ret, tmp;
                  
                  
            if (b.compareTo(zero) == 0)
                  
            {
                      x 
            = new BigInteger(new String("1"));
                      y 
            = zero;
                      
            return a;
                  }

                  ret 
            = extended_gcd(b, a.mod(b));
                  tmp 
            = x;
                  x 
            = y;
                  y 
            = tmp.subtract(a.divide(b).multiply(y));
                  
                  
            return ret;
              }

              
              
            static BigInteger modular_linear_equation(BigInteger a, BigInteger b, BigInteger n)
              
            {
                  BigInteger e, e2;
                  BigInteger d 
            = extended_gcd(a, n);
                  e 
            = b.divide(d).multiply(x).mod(n.divide(d));
                  e2 
            = e.subtract(n.divide(d)).abs();
                  
                  
            if (e.compareTo(e2) < 0)    return e;
                  
            return e2;
              }

              
              
            public static void main(String[] args)
              
            {
                  BigInteger a, b, c;
                  Scanner in 
            = new Scanner(System.in);
                
                  
            while (in.hasNext())
                  
            {
                      a 
            = in.nextBigInteger();
                      b 
            = in.nextBigInteger();
                      c 
            = in.nextBigInteger();
                      c 
            = c.multiply(new BigInteger(new String("-1")));
                      System.out.println(modular_linear_equation(a, c, b));
                  }

              }

            }
            posted on 2009-03-17 20:16 sdfond 閱讀(178) 評論(0)  編輯 收藏 引用 所屬分類: Algorithm - Number Theory
            亚洲欧洲久久久精品| 久久精品国产亚洲欧美| 欧美性猛交xxxx免费看久久久| 国产一区二区精品久久岳| 三级韩国一区久久二区综合 | 亚洲国产高清精品线久久| 人人狠狠综合久久亚洲高清| 中文字幕人妻色偷偷久久| 99久久久精品免费观看国产| 国产综合成人久久大片91| 无码人妻精品一区二区三区久久| 久久久国产精品福利免费| 亚洲欧美国产精品专区久久| 久久人人妻人人爽人人爽| 久久久久无码中| 亚洲色欲久久久综合网| 国产亚洲美女精品久久久| 久久婷婷五月综合97色| 伊人久久大香线蕉无码麻豆| 国内精品久久久久| 日本人妻丰满熟妇久久久久久| 国产农村妇女毛片精品久久| 久久久久久国产精品免费无码| 久久精品一区二区三区中文字幕 | 国产欧美久久久精品| 久久精品无码一区二区WWW| 久久99精品九九九久久婷婷| 久久天天躁狠狠躁夜夜网站| 伊人情人综合成人久久网小说| 99久久精品国产一区二区三区| 久久精品aⅴ无码中文字字幕不卡 久久精品aⅴ无码中文字字幕重口 | 久久久久久国产精品美女| 国产精品久久久99| 国产成人综合久久综合| 国产精品美女久久久m| 人妻丰满AV无码久久不卡| 久久久无码精品亚洲日韩蜜臀浪潮| 国产精品欧美久久久久无广告 | 狠狠色婷婷久久综合频道日韩 | 性做久久久久久久久久久| 国产精品99久久不卡|