• <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)

            隨筆分類(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 閱讀(185) 評論(0)  編輯 收藏 引用 所屬分類: Algorithm - Number Theory
            久久夜色精品国产www| 久久精品国产亚洲av麻豆图片 | 99久久99久久久精品齐齐| 狠狠色婷婷综合天天久久丁香| 久久精品国产亚洲精品| 色婷婷综合久久久久中文| 久久男人AV资源网站| 久久91精品国产91久久户| 一本色综合网久久| 久久人妻少妇嫩草AV无码蜜桃 | 久久久久久a亚洲欧洲aⅴ| 老男人久久青草av高清| 久久久久亚洲AV成人网人人软件| 欧洲人妻丰满av无码久久不卡| 亚洲精品无码久久毛片| 国产精品欧美久久久久无广告| 亚洲AV日韩精品久久久久| yy6080久久| 久久久黄色大片| 武侠古典久久婷婷狼人伊人| 久久久久99精品成人片三人毛片| 久久免费精品视频| 精品久久一区二区| 久久精品国产亚洲综合色| 国内精品伊人久久久久| 久久国产精品-国产精品| 国产精品久久久久影视不卡| 久久精品国产亚洲av影院| 国产精品一区二区久久不卡| 久久综合狠狠综合久久| 久久久精品人妻一区二区三区蜜桃| 国产69精品久久久久久人妻精品| 久久无码专区国产精品发布 | 久久免费精品一区二区| 亚洲国产成人久久精品影视| 国产 亚洲 欧美 另类 久久| 久久国产成人午夜aⅴ影院| 午夜精品久久久久久| 久久99热这里只频精品6| 亚洲国产精品无码久久一区二区| 国产成年无码久久久久毛片|