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

            公告

            記錄我的生活和工作。。。
            <2012年11月>
            28293031123
            45678910
            11121314151617
            18192021222324
            2526272829301
            2345678

            統(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 閱讀(220) 評論(0)  編輯 收藏 引用


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


            統(tǒng)計系統(tǒng)
            狠狠色丁香久久婷婷综| 久久这里只精品99re66| 国产2021久久精品| 久久精品夜色噜噜亚洲A∨| 久久亚洲国产成人影院网站| 亚洲一级Av无码毛片久久精品| 久久亚洲日韩看片无码| 久久免费国产精品一区二区| 亚洲国产精品综合久久网络 | 国产午夜久久影院| 亚洲国产精品成人久久蜜臀| 国产麻豆精品久久一二三| 欧美日韩成人精品久久久免费看 | 亚洲中文久久精品无码| 久久天天日天天操综合伊人av| 天天躁日日躁狠狠久久| 中文字幕亚洲综合久久菠萝蜜| 久久精品国产亚洲AV大全| 伊人久久无码精品中文字幕| 久久久久久久综合日本亚洲 | 久久丝袜精品中文字幕| 久久香蕉一级毛片| 久久精品国产网红主播| 色综合久久久久久久久五月| 久久天天躁狠狠躁夜夜不卡| 久久久WWW成人免费精品| 99久久亚洲综合精品成人| 久久国产精品一国产精品金尊| 久久午夜无码鲁丝片秋霞 | 91精品国产综合久久久久久| 亚洲国产精品无码久久一线| 伊人色综合久久天天人守人婷 | 久久se精品一区精品二区国产| 成人资源影音先锋久久资源网| 色综合久久久久综合体桃花网| 久久精品国产亚洲AV影院| 亚洲天堂久久久| 香蕉久久夜色精品国产尤物| 久久99九九国产免费看小说| 亚洲伊人久久综合中文成人网| 亚洲精品国精品久久99热|