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

            O(1) 的小樂

            Job Hunting

            公告

            記錄我的生活和工作。。。
            <2010年9月>
            2930311234
            567891011
            12131415161718
            19202122232425
            262728293012
            3456789

            統(tǒng)計

            • 隨筆 - 182
            • 文章 - 1
            • 評論 - 41
            • 引用 - 0

            留言簿(10)

            隨筆分類(70)

            隨筆檔案(182)

            文章檔案(1)

            如影隨形

            搜索

            •  

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            Project Euler 140

            Need Patience!!calm down..

            We get A(x) = (x + 3x2)/(1 - x - x2) = n is positive integer.
            Then:
            (n + 3)x2 + (n + 1)x - n = 0
            D = 5n2 + 14n + 1 = m2 for some integer m.
            Again we get:
            5n2 + 14n - (m2 - 1) = 0
            D = 5m2 + 44 = t2 for some integer t.
            We get more general Pell's equation in the form t2 - 5m2 = 44.
            I used http://mathworld.wolfram.com/PellEquation.html and .
            First solve "unit" form of this equation r2 - 5s2 = 1. First solution is (9, 4), then use recurence formula r(i + 1) = r(1)r(i) + 5s(1)s(i) and s(i + 1) = r(1)s(i) + s(1)r(i) to get all other solutions.
            Then build set of soutions of t2 - 5m2 = 44 using it's set of fundamental solutions:{(t, m)} = {(7, 1), (8, 2), (13, 5), (17, 7), (32, 14), (43, 19)} and using the identity t2 - 5m2 = (t2 - 5m2)(r2 - 5s2) = (tr + 5ms)2 - 5(ts + mr)2 = 44. This gives tr + 5ms for the new value of t.
            Finally, if t % 5 == 2 then n = (t - 7)/5 :)
            My very simple program is:

            Java

            [hide code]

            public class Problem140 {
                public static void main(String[] args) {
                    long g, t, n;
                    long[] p = {7, 8, 13, 17, 32, 43};
                    long[] q = {1, 2, 5, 7, 14, 19};
                    long[] r = {9, 9, 9, 9, 9, 9};
                    long[] s = {4, 4, 4, 4, 4, 4};   int count = 5;
                    // First 5 values of n
                    long sum = 2 + 5 + 21 + 42 + 152;   while (true) {
                        for (int k = 0; k < 6; k++) {
                            g = r[k];
                            r[k] = 9 * r[k] + 20 * s[k];
                            s[k] = 9 * s[k] + 4 * g;
                            t = p[k] * r[k] + 5 * q[k] * s[k];   if (t % 5 == 2) {
                                n = (t - 7) / 5;
                                sum += n;
                                count++;
                                System.out.println("n(" + count + ")=" + n);
                                if (count == 30) {
                                    System.out.println("Sum=" + sum);
                                    return;
                                }
                            }
                        }
                    }
                }
            }

             

             

            Answer:

            5673835352990

            posted on 2010-09-17 21:15 Sosi 閱讀(216) 評論(0)  編輯 收藏 引用


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            統(tǒng)計系統(tǒng)
            国产精品欧美久久久天天影视| 久久精品国产亚洲AV无码娇色 | 午夜欧美精品久久久久久久 | 久久久久久国产精品免费免费| 99久久超碰中文字幕伊人| A级毛片无码久久精品免费| 99精品国产免费久久久久久下载| 亚洲国产精品成人久久蜜臀| 色欲综合久久躁天天躁| 蜜桃麻豆www久久国产精品| 热久久国产欧美一区二区精品| 精品多毛少妇人妻AV免费久久| 国产精品青草久久久久婷婷| 伊人色综合久久| 久久精品免费网站网| 免费一级欧美大片久久网| 色综合久久夜色精品国产| 一本色综合久久| 色诱久久久久综合网ywww| 久久久久人妻一区精品色| 精品少妇人妻av无码久久| 久久久青草久久久青草| 国产精品免费看久久久香蕉| 精品无码人妻久久久久久| 欧美麻豆久久久久久中文| 国产成人无码精品久久久性色 | 亚洲欧美日韩精品久久| 成人午夜精品久久久久久久小说 | 99久久夜色精品国产网站| 久久精品中文无码资源站| 成人午夜精品久久久久久久小说 | 人人狠狠综合久久亚洲婷婷| 国产免费久久精品丫丫| 亚洲国产综合久久天堂 | 人妻中文久久久久| 久久亚洲AV无码精品色午夜 | 97久久国产亚洲精品超碰热 | 青青草国产97免久久费观看| 久久精品一区二区三区AV| 国产午夜免费高清久久影院| 精品久久久久国产免费|