• <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
            <2010年2月>
            31123456
            78910111213
            14151617181920
            21222324252627
            28123456
            78910111213

            常用鏈接

            留言簿(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 閱讀(178) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): Algorithm - Number Theory
            久久毛片免费看一区二区三区| 日本精品久久久久久久久免费| 久久精品无码一区二区无码| 国产精品视频久久久| 久久久国产精华液| 亚洲欧美久久久久9999| 亚洲AV无码久久精品色欲| 国产精品久久久天天影视| 国产精品99久久久久久宅男| 综合久久精品色| 国内精品久久国产大陆| 欧美黑人激情性久久| 久久亚洲国产精品一区二区| 一本一本久久aa综合精品| 婷婷久久综合九色综合98| 欧美色综合久久久久久| 99久久99久久| 精品熟女少妇av免费久久| 久久久久久久亚洲精品| 精品综合久久久久久97超人 | 久久亚洲精品中文字幕| 91精品国产色综久久| 亚洲精品蜜桃久久久久久| 久久国产午夜精品一区二区三区| 亚洲AV无码久久| 亚洲综合久久夜AV | 一级做a爰片久久毛片看看| 国产精品久久久久久久久鸭| 天天爽天天狠久久久综合麻豆| 亚洲精品久久久www| 久久综合伊人77777麻豆| 久久精品亚洲欧美日韩久久| 精品人妻伦九区久久AAA片69| 色成年激情久久综合| 91久久精一区二区三区大全| 久久精品国产亚洲精品2020| 久久亚洲精品成人AV| 久久精品一本到99热免费| 蜜臀久久99精品久久久久久| 93精91精品国产综合久久香蕉 | 亚洲va中文字幕无码久久|