• <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
            久久久久久曰本AV免费免费| 国产成人久久精品激情 | 久久福利青草精品资源站| 色欲综合久久躁天天躁蜜桃| 久久99国产精品久久99| 蜜桃麻豆www久久国产精品| 囯产精品久久久久久久久蜜桃| 国产精品久久久久AV福利动漫| 亚洲国产成人久久精品动漫| 久久久亚洲AV波多野结衣| 久久久中文字幕| 久久99精品久久久大学生| 国产精品久久久久久久午夜片| 噜噜噜色噜噜噜久久| 日本精品久久久久中文字幕| 久久无码专区国产精品发布| 国产精品综合久久第一页| 色婷婷综合久久久久中文一区二区| 国产精品欧美久久久久无广告| 人妻丰满AV无码久久不卡| 伊人久久大香线蕉综合Av| 欧美粉嫩小泬久久久久久久| a级毛片无码兔费真人久久| 亚洲国产另类久久久精品| 午夜精品久久影院蜜桃| 国产亚洲精久久久久久无码AV| 久久精品国产亚洲AV麻豆网站| 久久婷婷国产剧情内射白浆| 久久久久久A亚洲欧洲AV冫| 久久国产亚洲高清观看| 欧美黑人又粗又大久久久| 日本五月天婷久久网站| 伊人情人综合成人久久网小说| 久久精品不卡| 久久精品国产99久久丝袜| 国产精品欧美亚洲韩国日本久久| 青青国产成人久久91网| 国产精品成人精品久久久| 久久国产V一级毛多内射| 狠狠色综合网站久久久久久久| 久久精品国产亚洲7777|