• <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年5月>
            262728293012
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            常用鏈接

            留言簿(8)

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

            隨筆檔案(68)

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

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

            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 閱讀(185) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): Algorithm - Number Theory
            国产精品久久久99| 亚洲国产综合久久天堂| 精品久久久久久国产| 精品久久久无码中文字幕天天| 久久综合视频网站| 精品国产乱码久久久久久1区2区| 99国内精品久久久久久久| 久久久国产99久久国产一| 99久久免费国产精品| 久久婷婷激情综合色综合俺也去| 成人亚洲欧美久久久久| 久久久久久国产精品无码超碰| 人妻少妇精品久久| 2020最新久久久视精品爱| 久久免费的精品国产V∧| 久久天天躁狠狠躁夜夜2020| 久久久久亚洲AV无码专区体验| 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 精品久久久久久亚洲精品| 久久精品国产亚洲av瑜伽| 久久夜色精品国产亚洲| 无码伊人66久久大杳蕉网站谷歌| 久久夜色精品国产| 精品久久久久久无码人妻蜜桃| 国产精品久久久久久影院| 午夜精品久久久久久久久| 无码国内精品久久人妻蜜桃| 国产69精品久久久久APP下载| 久久精品综合一区二区三区| 国产成人综合久久久久久| 久久久久综合网久久| 国产精品久久成人影院| 久久综合综合久久综合| 奇米综合四色77777久久| 久久精品亚洲精品国产色婷 | 色综合久久综精品| 久久久久久久尹人综合网亚洲 | 亚洲狠狠久久综合一区77777| 国产精品岛国久久久久| 国产精品99久久久久久董美香| 久久91精品综合国产首页|