周五轻松一下:奇妙序列

Posted 牧师的博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了周五轻松一下:奇妙序列相关的知识,希望对你有一定的参考价值。

很久没来博客园了,最近来逛贴,优质帖也多了不少。

昨天看到烟花散尽13141 的发帖,有提到leetcode,然后也去逛了一下,像是发现宝藏一样,我个人对这个网站的评价还是很高。

 

leetcode这个网站从它的建站思想上来说还是很有意思的,也许在不久的将来,会成为软件技术员的后花园。

我能看到它的优势在哪儿:

1.学习、题库、竞赛、求职。

  这简单的8个字基本上涵盖了一个程序员的一生,而且是从萌芽时期开始的,并不像其他技术站,多数人都是半途才加入。这样的群体一般都比较牢靠,忠诚度比较高。

2.从传统的观看、理解,到直接动手参与解决问题,劳智结合。

  这种不做评价,都是学过来的,哪种方式更深刻的学习和记忆、更能拔高能力不言而喻。

3.在这里,不是依靠偷几篇文章做吸睛,竞赛时刻,真的靠真材实料,因为找不到任何可帮助的资源。

  说起这个我还真是个剽窃高手,做了多年互联网监控,自己的知识库全靠剽窃充盈起来的。

 

 

======================================================================

  昨天去leetcode看了看,看了有俩小时,看它的网站架构,然后看了看并试着做了做题库,看的时候感觉很简单,结果做的时候......

选了三个难的,两个过了,一个怎么都过不去,这个是真不会,完全没思路了。

然后选了俩简单的,一过一不过,那个过不去的还是觉得一点头绪都没,主要是要求的时间复杂度没法实现。

 

  今天周五了,找个习题放松下。

======================================================================

来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/fancy-sequence

1622. 奇妙序列】  困难级别  目前通过人次统计:通过次数1,754 提交次数12,322

----------------------------------------------------------------------------------------------------------------

请你实现三个 API append,addAll 和 multAll 来实现奇妙序列。

请实现 Fancy 类 :

Fancy() 初始化一个空序列对象。
void append(val) 将整数 val 添加在序列末尾。
void addAll(inc) 将所有序列中的现有数值都增加 inc 。
void multAll(m) 将序列中的所有现有数值都乘以整数 m 。
int getIndex(idx) 得到下标为 idx 处的数值(下标从 0 开始),并将结果对 109 + 7 取余。如果下标大于等于序列的长度,请返回 -1 。
 

示例:

输入:
["Fancy", "append", "addAll", "append", "multAll", "getIndex", "addAll", "append", "multAll", "getIndex", "getIndex", "getIndex"]
[[], [2], [3], [7], [2], [0], [3], [10], [2], [0], [1], [2]]
输出:
[null, null, null, null, null, 10, null, null, null, 26, 34, 20]

解释:
Fancy fancy = new Fancy();
fancy.append(2); // 奇妙序列:[2]
fancy.addAll(3); // 奇妙序列:[2+3] -> [5]
fancy.append(7); // 奇妙序列:[5, 7]
fancy.multAll(2); // 奇妙序列:[5*2, 7*2] -> [10, 14]
fancy.getIndex(0); // 返回 10
fancy.addAll(3); // 奇妙序列:[10+3, 14+3] -> [13, 17]
fancy.append(10); // 奇妙序列:[13, 17, 10]
fancy.multAll(2); // 奇妙序列:[13*2, 17*2, 10*2] -> [26, 34, 20]
fancy.getIndex(0); // 返回 26
fancy.getIndex(1); // 返回 34
fancy.getIndex(2); // 返回 20
 

提示:

1 <= val, inc, m <= 100
0 <= idx <= 105
总共最多会有 105 次对 append,addAll,multAll 和 getIndex 的调用。

----------------------------------------------------------------------------------------------------------------

这个题其实还是非常简单的,很多人败在这个题上,应该是被它庞大的解释给吓退了,其实它的解释就是答案,照抄解释就算完成了。

还有就是这个题的内部验证数组应该有20+,而且验证数组还比较大,我觉得我的验证时间太长了,50秒。我自己在浏览器中也就跑了2、 3秒。

通过这个题目,也从侧面反映出同学们的理解能力有多么的令人担忧。

array_func = ["Fancy", "append", "append", "append", "append", "append", "append", "addAll", "multAll", "multAll", "append", "addAll", "append", "getIndex", "addAll", "append", "append", "append", "getIndex", "multAll", "getIndex", "getIndex", "multAll", "getIndex", "getIndex", "multAll", "append", "append", "append", "append", "multAll", "append", "multAll", "addAll", "getIndex", "addAll", "addAll", "addAll", "getIndex", "addAll", "append", "addAll", "addAll", "addAll", "append", "multAll", "addAll", "append", "append", "addAll", "append", "addAll", "getIndex", "append", "multAll", "getIndex", "addAll", "multAll", "append", "append", "addAll", "append", "getIndex", "multAll", "append", "addAll", "append", "append", "getIndex", "getIndex", "addAll", "multAll", "getIndex", "multAll", "getIndex", "multAll", "append", "append", "multAll", "getIndex", "getIndex", "multAll", "append", "multAll", "addAll", "multAll", "multAll", "getIndex", "append", "getIndex"]
array_para = [[], [15], [6], [9], [13], [13], [7], [1], [14], [14], [10], [8], [2], [0], [15], [3], [12], [1], [2], [12], [7], [9], [2], [4], [1], [9], [1], [8], [13], [4], [12], [7], [8], [10], [1], [15], [14], [1], [15], [4], [9], [2], [7], [11], [12], [3], [14], [4], [2], [3], [4], [12], [7], [8], [12], [10], [1], [9], [4], [13], [4], [8], [15], [12], [12], [11], [8], [14], [18], [3], [15], [4], [0], [5], [13], [10], [6], [3], [15], [17], [0], [4], [12], [9], [14], [3], [10], [17], [8], [0]]

var Run = function () {
    for (let i = 0; i < array_func.length; i++) {
        switch (array_func[i]) {
            case "Fancy": Fancy(); break;
            case "append": Fancy.prototype.append(array_para[i][0]); break;
            case "addAll": Fancy.prototype.addAll(array_para[i][0]); break;
            case "multAll": Fancy.prototype.multAll(array_para[i][0]); break;
            case "getIndex": Fancy.prototype.getIndex(array_para[i][0]); break;

        }
    }
}

var Fancy = function () {
    // console.log(\'初始化空队列\');
    array = [];
};

/** 
 * @param {number} val
 * @return {void}
 */
Fancy.prototype.append = function (val) {
    array.push(val);
    // console.log(\'append\', val, array);
};

/** 
 * @param {number} inc
 * @return {void}
 */
Fancy.prototype.addAll = function (inc) {
    for (let i = 0; i < array.length; i++) {
        array[i] += inc;
        if (array[i] > 1e9 + 7)
            array[i] = array[i] % (1e9 + 7);
    }
    // console.log(\'addAll\', inc, array);
};

/** 
 * @param {number} m
 * @return {void}
 */
Fancy.prototype.multAll = function (m) {
    for (let i = 0; i < array.length; i++) {
        array[i] *= m;
        if (array[i] > 1e9 + 7)
            array[i] = array[i] % (1e9 + 7);
    }
    // console.log(\'multAll\', m, array);
};

/** 
 * @param {number} idx
 * @return {number}
 */
Fancy.prototype.getIndex = function (idx) {
    // console.log(\'getIndex\', idx, array);

    if (idx < 0 || idx >= array.length)
        return -1;

    return array[idx];
};
View Code

请注意:var Run = function () 这个是做测试写的方法,应该就是力扣后台的方法。提交代码时不要提交它。

array_func = ["Fancy", "append", "append", "append", "append", "append", "append", "addAll", "multAll", "multAll", "append", "addAll", "append", "getIndex", "addAll", "append", "append", "append", "getIndex", "multAll", "getIndex", "getIndex", "multAll", "getIndex", "getIndex", "multAll", "append", "append", "append", "append", "multAll", "append", "multAll", "addAll", "getIndex", "addAll", "addAll", "addAll", "getIndex", "addAll", "append", "addAll", "addAll", "addAll", "append", "multAll", "addAll", "append", "append", "addAll", "append", "addAll", "getIndex", "append", "multAll", "getIndex", "addAll", "multAll", "append", "append", "addAll", "append", "getIndex", "multAll", "append", "addAll", "append", "append", "getIndex", "getIndex", "addAll", "multAll", "getIndex", "multAll", "getIndex", "multAll", "append", "append", "multAll", "getIndex", "getIndex", "multAll", "append", "multAll", "addAll", "multAll", "multAll", "getIndex", "append", "getIndex"]
array_para = [[], [15], [6], [9], [13], [13], [7], [1], [14], [14], [10], [8], [2], [0], [15], [3], [12], [1], [2], [12], [7], [9], [2], [4], [1], [9], [1], [8], [13], [4], [12], [7], [8], [10], [1], [15], [14], [1], [15], [4], [9], [2], [7], [11], [12], [3], [14], [4], [2], [3], [4], [12], [7], [8], [12], [10], [1], [9], [4], [13], [4], [8], [15], [12], [12], [11], [8], [14], [18], [3], [15], [4], [0], [5], [13], [10], [6], [3], [15], [17], [0], [4], [12], [9], [14], [3], [10], [17], [8], [0]]

var Run = function () {
    for (let i = 0; i < array_func.length; i++) {
        switch (array_func[i]) {
            case "Fancy": Fancy(); break;
            case "append": Fancy.prototype.append(array_para[i][0]); break;
            case "addAll": Fancy.prototype.addAll(array_para[i][0]); break;
            case "multAll": Fancy.prototype.multAll(array_para[i][0]); break;
            case "getIndex": Fancy.prototype.getIndex(array_para[i][0]); break;

        }
    }
}

var Fancy = function () {
    console.log(\'初始化空队列\');
    array = [];
};

/**
 * @param {number} val
 * @return {void}
 */
Fancy.prototype.append = function (val) {
    array.push(val);
    console.log(\'append\', val, array);
};

/**
 * @param {number} inc
 * @return {void}
 */
Fancy.prototype.addAll = function (inc) {
    for (let i = 0; i < array.length; i++) {
        array[i] += inc;
        if (array[i] > 1e9 + 7)
            array[i] = array[i] % (1e9 + 7);
    }
    console.log(\'addAll\', inc, array);
};

/**
 * @param {number} m
 * @return {void}
 */
Fancy.prototype.multAll = function (m) {
    for (let i = 0; i < array.length; i++) {
        array[i] *= m;
        if (array[i] > 1e9 + 7)
            array[i] = array[i] % (1e9 + 7);
    }
    console.log(\'multAll\', m, array);
};

/**
 * @param {number} idx
 * @return {number}
 */
Fancy.prototype.getIndex = function (idx) {
    console.log(\'getIndex\', idx, array);

    if (idx < 0 || idx >= array.length)
        return -1;

    if (array[idx] >= 1e9 + 7)
        return array[idx] % (1e9 + 7);
    else
        return array[idx];
};
ƒ (idx) {
    console.log(\'getIndex\', idx, array);

    if (idx < 0 || idx >= array.length)
        return -1;

    if (array[idx] >= 1e9 + 7)
        return array[idx] % (1e9 + 7);
    else
        re…
Run()
VM2202:18 初始化空队列
VM2202:28 append 15 [15]
VM2202:28 append 6 (2) [15, 6]
VM2202:28 append 9 (3) [15, 6, 9]
VM2202:28 append 13 (4) [15, 6, 9, 13]
VM2202:28 append 13 (5) [15, 6, 9, 13, 13]
VM2202:28 append 7 (6) [15, 6, 9, 13, 13, 7]
VM2202:41 addAll 1 (6) [16, 7, 10, 14, 14, 8]
VM2202:54 multAll 14 (6) [224, 98, 140, 196, 196, 112]
VM2202:54 multAll 14 (6) [3136, 1372, 1960, 2744, 2744, 1568]
VM2202:28 append 10 (7) [3136, 1372, 1960, 2744, 2744, 1568, 10]
VM2202:41 addAll 8 (7) [3144, 1380, 1968, 2752, 2752, 1576, 18]
VM2202:28 append 2 (8) [3144, 1380, 1968, 2752, 2752, 1576, 18, 2]
VM2202:62 getIndex 0 (8) [3144, 1380, 1968, 2752, 2752, 1576, 18, 2]
VM2202:41 addAll 15 (8) [3159, 1395, 1983, 2767, 2767, 1591, 33, 17]
VM2202:28 append 3 (9) [3159, 1395, 1983, 2767, 2767, 1591, 33, 17, 3]
VM2202:28 append 12 (10) [3159, 1395, 1983, 2767, 2767, 1591, 33, 17, 3, 12]
VM2202:28 append 1 (11) [3159, 1395, 1983, 2767, 2767, 1591, 33, 17, 3, 12, 1]
VM2202:62 getIndex 2 (11) [3159, 1395, 1983, 2767, 2767, 1591, 33, 17, 3, 12, 1]
VM2202:54 multAll 12 (11) [37908, 16740, 23796, 33204, 33204, 19092, 396, 204, 36, 144, 12]
VM2202:62 getIndex 7 (11) [37908, 16740, 23796, 33204, 33204, 19092, 396, 204, 36, 144, 12]
VM2202:62 getIndex 9 (11) [37908, 16740, 23796, 33204, 33204, 19092, 396, 204, 36, 144, 12]
VM2202:54 multAll 2 (11) [75816, 33480, 47592, 66408, 66408, 38184, 792, 408, 72, 288, 24]
VM2202:62 getIndex 4 (11) [75816, 33480, 47592, 66408, 66408, 38184, 792, 408, 72, 288, 24]
VM2202:62 getIndex 1 (11) [75816, 33480, 47592, 66408, 66408, 38184, 792, 408, 72, 288, 24]
VM2202:54 multAll 9 (11) [682344, 301320, 428328, 597672, 597672, 343656, 7128, 3672, 648, 2592, 216]
VM2202:28 append 1 (12) [682344, 301320, 428328, 597672, 597672, 343656, 7128, 3672, 648, 2592, 216, 1]
VM2202:28 append 8 (13) [682344, 301320, 428328, 597672, 597672, 343656, 7128, 3672, 648, 2592, 216, 1, 8]
VM2202:28 append 13 (14) [682344, 301320, 428328, 597672, 597672, 343656, 7128, 3672, 648, 2592, 216, 1, 8, 13]
VM2202:28 append 4 (15) [682344, 301320, 428328, 597672, 597672, 343656, 7128, 3672, 648, 2592, 216, 1, 8, 13, 4]
VM2202:54 multAll 12 (15) [8188128, 3615840, 5139936, 7172064, 7172064, 4123872, 85536, 44064, 7776, 31104, 2592, 12, 96, 156, 48]
VM2202:28 append 7 (16) [8188128, 3615840, 5139936, 7172064, 7172064, 4123872, 85536, 44064, 7776, 31104, 2592, 12, 96, 156, 48, 7]
VM2202:54 multAll 8 (16) [65505024, 28926720, 41119488, 57376512, 57376512, 32990976, 684288, 352512, 62208, 248832, 20736, 96, 768, 1248, 384, 56]
VM2202:41 addAll 10 (16) [65505034, 28926730, 41119498, 57376522, 57376522, 32990986, 684298, 352522, 62218, 248842, 20746, 106, 778, 1258, 394, 66]
VM2202:62 getIndex 1 (16) [65505034, 28926730, 41119498, 57376522, 57376522, 32990986, 684298, 352522, 62218, 248842, 20746, 106, 778, 1258, 394, 66]
VM2202:41 addAll 15 (16) [65505049, 28926745, 41119513, 57376537, 57376537, 32991001, 684313, 352537, 62233, 248857, 20761, 121, 793, 1273, 409, 81]
VM2202:41 addAll 14 (16) [65505063, 28926759, 41119527, 57376551, 57376551, 32991015, 684327, 352551, 62247, 248871, 20775, 135, 807, 1287, 423, 95]
VM2202:41 addAll 1 (16) [65505064, 28926760, 41119528, 57376552, 57376552, 32991016, 684328, 352552, 62248, 248872, 20776, 136, 808, 1288, 424, 96]
VM2202:62 getIndex 15 (16) [65505064, 28926760, 41119528, 57376552, 57376552, 32991016, 684328, 352552, 62248, 248872, 20776, 136, 808, 1288, 424, 96]
VM2202:41 addAll 4 (16) [65505068, 28926764, 41119532, 57376556, 57376556, 32991020, 684332, 352556, 62252, 248876, 20780, 140, 812, 1292, 428, 100]
VM2202:28 append 9 (17) [65505068, 28926764, 41119532, 57376556, 57376556, 32991020, 684332, 352556, 62252, 248876, 20780, 140, 812, 1292, 428, 100, 9]
VM2202:41 addAll 2 (17) [65505070, 28926766, 41119534, 57376558, 57376558, 32991022, 684334, 352558, 62254, 248878, 20782, 142, 814, 1294, 430, 102, 11]
VM2202:41 addAll 7 (17) [65505077, 28926773, 41119541, 57376565, 57376565, 32991029, 684341, 352565, 62261, 248885, 20789, 149, 821, 1301, 437, 109, 18]
VM2202:41 addAll 11 (17) [65505088, 28926784, 41119552, 57376576, 57376576, 32991040, 684352, 352576, 62272, 248896, 20800, 160, 832, 1312, 448, 120, 29]
VM2202:28 append 12 (18) [65505088, 28926784, 41119552, 57376576, 57376576, 32991040, 684352, 352576, 62272, 248896, 20800, 160, 832, 1312, 448, 120, 29, 12]
VM2202:54 multAll 3 (18) [196515264, 86780352, 123358656, 172129728, 172129728, 98973120, 2053056, 1057728, 186816, 746688, 62400, 480, 2496, 3936, 1344, 360, 87, 36]
VM2202:41 addAll 14 (18) [196515278, 86780366, 123358670, 172129742, 172129742, 98973134, 2053070, 1057742, 186830, 746702, 62414, 494, 2510, 3950, 1358, 374, 101, 50]
VM2202:28 append 4 (19) [196515278, 86780366, 123358670, 172129742, 172129742, 98973134, 2053070, 1057742, 186830, 746702, 62414, 494, 2510, 3950, 1358, 374, 101, 50, 4]
VM2202:28 append 2 (20) [196515278, 86780366, 123358670, 172129742, 172129742, 98973134, 2053070, 1057742, 186830, 746702, 62414, 494, 2510, 3950, 1358, 374, 101, 50, 4, 2]
VM2202:41 addAll 3 (20) [196515281, 86780369, 123358673, 172129745, 172129745, 98973137, 2053073, 1057745, 186833, 746705, 62417, 497, 2513, 3953, 1361, 377, 104, 53, 7, 5]
VM2202:28 append 4 (21) [196515281, 86780369, 123358673, 172129745, 172129745, 98973137, 2053073, 1057745, 186833, 746705, 62417, 497, 2513, 3953, 1361, 377, 104, 53, 7, 5, 4]
VM2202:41 addAll 12 (21) [196515293, 86780381, 123358685, 172129757, 172129757, 98973149, 2053085, 1057757, 186845, 746717, 62429, 509, 2525, 3965, 1373, 389, 116, 65, 19, 17, 16]
VM2202:62 getIndex 7 (21) [196515293, 86780381, 123358685, 172129757, 172129757, 98973149, 2053085, 1057757, 186845, 746717, 62429, 509, 2525, 3965, 1373, 389, 116, 65, 19, 17, 16]
VM2202:28 append 8 (22) [196515293, 86780381, 123358685, 172129757, 172129757, 98973149, 2053085, 1057757, 186845, 746717, 62429, 509, 2525, 3965, 1373, 389, 116, 65, 19, 17, 16, 8]
VM2202:54 multAll 12 (22) [358183502, 41364565, 480304213, 65557070, 65557070, 187677781, 24637020, 12693084, 2242140, 8960604, 749148, 6108, 30300, 47580, 16476, 4668, 1392, 780, 228, 204, 192, 96]
VM2202:62 getIndex 10 (22) [358183502, 41364565, 480304213, 65557070, 65557070, 187677781, 24637020, 12693084, 2242140, 8960604, 749148, 6108, 30300, 47580, 16476, 4668, 1392, 780, 228, 204, 192, 96]
VM2202:41 addAll 1 (22) [358183503, 41364566, 480304214, 65557071, 65557071, 187677782, 24637021, 12693085, 2242141, 8960605, 749149, 6109, 30301, 47581, 16477, 4669, 1393, 781, 229, 205, 193, 97]
VM2202:54 multAll 9 (22) [223651506, 372281094, 322737898, 590013639, 590013639, 689100031, 221733189, 114237765, 20179269, 80645445, 6742341, 54981, 272709, 428229, 148293, 42021, 12537, 7029, 2061, 1845, 1737, 873]
VM2202:28 append 4 (23) [223651506, 372281094, 322737898, 590013639, 590013639, 689100031, 221733189, 114237765, 20179269, 80645445, 6742341, 54981, 272709, 428229, 148293, 42021, 12537, 7029, 2061, 1845, 1737, 873, 4]
VM2202:28 append 13 (24) [223651506, 372281094, 322737898, 590013639, 590013639, 689100031, 221733189, 114237765, 20179269, 80645445, 6742341, 54981, 272709, 428229, 148293, 42021, 12537, 7029, 2061, 1845, 1737, 873, 4, 13]
VM2202:41 addAll 4 (24) [223651510, 372281098, 322737902, 590013643, 590013643, 689100035, 221733193, 114237769, 20179273, 80645449, 6742345, 54985, 272713, 428233, 148297, 42025, 12541, 7033, 2065, 1849, 1741, 877, 8, 17]
VM2202:28 append 8 (25) [223651510, 372281098, 322737902, 590013643, 590013643, 689100035, 221733193, 114237769, 20179273, 80645449, 6742345, 54985, 272713, 428233, 148297, 42025, 12541, 7033, 2065, 1849, 1741, 877, 8, 17, 8]
VM2202:62 getIndex 15 (25) [223651510, 372281098, 322737902, 590013643, 590013643, 689100035, 221733193, 114237769, 20179273, 80645449, 6742345, 54985, 272713, 428233, 148297, 42025, 12541, 7033, 2065, 1849, 1741, 877, 8, 17, 8]
VM2202:54 multAll 12 (25) [683818106, 467373148, 872854803, 80163667, 80163667, 269200364, 660798302, 370853221, 242151276, 967745388, 80908140, 659820, 3272556, 5138796, 1779564, 504300, 150492, 84396, 24780, 22188, 20892, 10524, 96, 204, 96]
VM2202:28 append 12 (26) [683818106, 467373148, 872854803, 80163667, 80163667, 269200364, 660798302, 370853221, 242151276, 967745388, 80908140, 659820, 3272556, 5138796, 1779564, 504300, 150492, 84396, 24780, 22188, 20892, 10524, 96, 204, 96, 12]
VM2202:41 addAll 11 (26) [683818117, 467373159, 872854814, 80163678, 80163678, 269200375, 660798313, 370853232, 242151287, 967745399, 80908151, 659831, 3272567, 5138807, 1779575, 504311, 150503, 84407, 24791, 22199, 20903, 10535, 107, 215, 107, 23]
VM2202:28 append 8 (27) [683818117, 467373159, 872854814, 80163678, 80163678, 269200375, 660798313, 370853232, 242151287, 967745399, 80908151, 659831, 3272567, 5138807, 1779575, 504311, 150503, 84407, 24791, 22199, 20903, 10535, 107, 215, 107, 23, 8]
VM2202:28 append 14 (28) [683818117, 467373159, 872854814, 80163678, 80163678, 269200375, 660798313, 370853232, 242151287, 967745399, 80908151, 659831, 3272567, 5138807, 1779575, 504311, 150503, 84407, 24791, 22199, 20903, 10535, 107, 215, 107, 23, 8, 14]
VM2202:62 getIndex 18 (28) [683818117, 467373159, 872854814, 80163678, 80163678, 269200375, 660798313, 370853232, 242151287, 967745399, 80908151, 659831, 3272567, 5138807, 1779575, 504311, 150503, 84407, 24791, 22199, 20903, 10535, 107, 215, 107, 23, 8, 14]
VM2202:62 getIndex 3 (28) [683818117, 467373159, 872854814, 80163678, 80163678, 269200375, 660798313, 370853232, 242151287, 967745399, 80908151, 659831, 3272567, 5138807, 1779575, 504311, 150503, 84407, 24791, 22199, 20903, 10535, 107, 215, 107, 23, 8, 14]
VM2202:41 addAll 15 (28) [683818132, 467373174, 872854829, 80163693, 80163693, 269200390, 660798328, 370853247, 242151302, 967745414, 80908166, 659846, 3272582, 5138822, 1779590, 504326, 150518, 84422, 24806, 22214, 20918, 10550, 122, 230, 122, 38, 23, 29]
VM2202:54 multAll 4 (28) [735272514, 869492689, 491419295, 320654772, 320654772, 76801553, 643193298, 483412981, 968605208, 870981635, 323632664, 2639384, 13090328, 20555288, 7118360, 2017304, 602072, 337688, 99224, 88856, 83672, 42200, 488, 920, 488, 152, 92, 116]
VM2202:62 getIndex 0 (28) [735272514, 869492689, 491419295, 320654772, 320654772, 76801553, 643193298, 483412981, 968605208, 870981635, 323632664, 2639384, 13090328, 20555288, 7118360, 2017304, 602072, 337688, 99224, 88856, 83672, 42200, 488, 920, 488, 152, 92, 116]
VM2202:54 multAll 5 (28) [676362549, 347463417, 457096461, 603273853, 603273853, 384007765, 215966469, 417064891, 843026012, 354908147, 618163313, 13196920, 65451640, 102776440, 35591800, 10086520, 3010360, 1688440, 496120, 444280, 418360, 211000, 2440, 4600, 2440, 760, 460, 580]
VM2202:62 getIndex 13 (28) [676362549, 347463417, 457096461, 603273853, 603273853, 384007765, 215966469, 417064891, 843026012, 354908147, 618163313, 13196920, 65451640, 102776440, 35591800, 10086520, 3010360, 1688440, 496120, 444280, 418360, 211000, 2440, 4600, 2440, 760, 460, 580]
VM2202:54 multAll 10 (28) [763625448, 474634149, 570964582, 32738488, 32738488, 840077629, 159664676, 170648882, 430260064, 549081449, 181633088, 131969200, 654516400, 27764393, 355918000, 100865200, 30103600, 16884400, 4961200, 4442800, 4183600, 2110000, 24400, 46000, 24400, 7600, 4600, 5800]
VM2202:28 append 6 (29) [763625448, 474634149, 570964582, 32738488, 32738488, 840077629, 159664676, 170648882, 430260064, 549081449, 181633088, 131969200, 654516400, 27764393, 355918000, 100865200, 30103600, 16884400, 4961200, 4442800, 4183600, 2110000, 24400, 46000, 24400, 7600, 4600, 5800, 6]
VM2202:28 append 3 (30) [763625448, 474634149, 570964582, 32738488, 32738488, 840077629, 159664676, 170648882, 430260064, 549081449, 181633088, 131969200, 654516400, 27764393, 355918000, 100865200, 30103600, 16884400, 4961200, 4442800, 4183600, 2110000, 24400, 46000, 24400, 7600, 4600, 5800, 6, 3]
VM2202:54 multAll 15 (30) [454381643, 119512186, 564468674, 491077320, 491077320, 601164351, 394970126, 559733216, 453900918, 236221679, 724496306, 979537993, 817745937, 416465895, 338769965, 512977993, 451554000, 253266000, 74418000, 66642000, 62754000, 31650000, 366000, 690000, 366000, 114000, 69000, 87000, 90, 45]
VM2202:62 getIndex 17 (30) [454381643, 119512186, 564468674, 491077320, 491077320, 601164351, 394970126, 559733216, 453900918, 236221679, 724496306, 979537993, 817745937, 416465895, 338769965, 512977993, 451554000, 253266000, 74418000, 66642000, 62754000, 31650000, 366000, 690000, 366000, 114000, 69000, 87000, 90, 45]
VM2202:62 getIndex 0 (30) [454381643, 119512186, 564468674, 491077320, 491077320, 601164351, 394970126, 559733216, 453900918, 236221679, 724496306, 979537993, 817745937, 416465895, 338769965, 512977993, 451554000, 253266000, 74418000, 66642000, 62754000, 31650000, 366000, 690000, 366000, 114000, 69000, 87000, 90, 45]
VM2202:54 multAll 4 (30) [817526565, 478048744, 257874682, 964309273, 964309273, 404657390, 579880497, 238932850, 815603665, 944886716, 897985210, 918151951, 270983727, 665863573, 355079853, 51911958, 806215993, 13063993, 297672000, 266568000, 251016000, 126600000, 1464000, 2760000, 1464000, 456000, 276000, 348000, 360, 180]
VM2202:28 append 12 (31) [817526565, 478048744, 257874682, 964309273, 964309273, 404657390, 579880497, 238932850, 815603665, 944886716, 897985210, 918151951, 270983727, 665863573, 355079853, 51911958, 806215993, 13063993, 297672000, 266568000, 251016000, 126600000, 1464000, 2760000, 1464000, 456000, 276000, 348000, 360, 180, 12]
VM2202:54 multAll 9 (31) [357739036, 302438668, 320872124, 678783401, 678783401, 641916489, 218924438, 150395636, 340432936, 503980388, 81866834, 263367503, 438853529, 992772122, 195718656, 467207622, 255943888, 117575937, 679047986, 399111986, 259143986, 139399993, 13176000, 24840000, 13176000, 4104000, 2484000, 3132000, 3240, 1620, 108]
VM2202:41 addAll 14 (31) [357739050, 302438682, 320872138, 678783415, 678783415, 641916503, 218924452, 150395650, 340432950, 503980402, 81866848, 263367517, 438853543, 992772136, 195718670, 467207636, 255943902, 117575951, 679048000, 399112000, 259144000, 139400007, 13176014, 24840014, 13176014, 4104014, 2484014, 3132014, 3254, 1634, 122]
VM2202:54 multAll 3 (31) [73217143, 907316046, 962616414, 36350231, 36350231, 925749502, 656773356, 451186950, 21298843, 511941199, 245600544, 790102551, 316560622, 978316394, 587156010, 401622901, 767831706, 352727853, 37143986, 197335993, 777432000, 418200021, 39528042, 74520042, 39528042, 12312042, 7452042, 9396042, 9762, 4902, 366]
VM2202:54 multAll 10 (31) [732171430, 73160397, 626164077, 363502310, 363502310, 257494957, 567733518, 511869472, 212988430, 119411955, 456005426, 901025461, 165606199, 783163877, 871560065, 16228982, 678317011, 527278509, 371439860, 973359923, 774319951, 182000182, 395280420, 745200420, 395280420, 123120420, 74520420, 93960420, 97620, 49020, 3660]
VM2202:62 getIndex 17 (31) [732171430, 73160397, 626164077, 363502310, 363502310, 257494957, 567733518, 511869472, 212988430, 119411955, 456005426, 901025461, 165606199, 783163877, 871560065, 16228982, 678317011, 527278509, 371439860, 973359923, 774319951, 182000182, 395280420, 745200420, 395280420, 123120420, 74520420, 93960420, 97620, 49020, 3660]
VM2202:28 append 8 (32) [732171430, 73160397, 626164077, 363502310, 363502310, 257494957, 567733518, 511869472, 212988430, 119411955, 456005426, 901025461, 165606199, 783163877, 871560065, 16228982, 678317011, 527278509, 371439860, 973359923, 774319951, 182000182, 395280420, 745200420, 395280420, 123120420, 74520420, 93960420, 97620, 49020, 3660, 8]
VM2202:62 getIndex 0 (32) [732171430, 73160397, 626164077, 363502310, 363502310, 257494957, 567733518, 511869472, 212988430, 119411955, 456005426, 901025461, 165606199, 783163877, 871560065, 16228982, 678317011, 527278509, 371439860, 973359923, 774319951, 182000182, 395280420, 745200420, 395280420, 123120420, 74520420, 93960420, 97620, 49020, 3660, 8]
undefined
浏览器控制台

array_func和array_para是输入参数,两组参数对应位置上,array_func中是调用的函数名,array_para中是函数执行的参数。这两组参数是官方给的,测试代码一旦出错会把输入输出都告诉你的。

这个题大概一小时内提交了8次,三次错误,四次超时,一次通过。因为超时我换用python和C++导致这题做时过长。之前怎么写的我记不清楚了,里面很关键的两句if (array[i] > 1e9 + 7)一定要if验证之后再取模,这个if之前没加是超时的主要原因。

这个测试在浏览器中做的,我本地只有终端的python、java、c++,写代码有点不太方便,就在浏览器里面测试了。

以上是关于周五轻松一下:奇妙序列的主要内容,如果未能解决你的问题,请参考以下文章

浙江选考技术周五干货浅谈冒泡排序中的“交换次数”

css常用代码片段 (更新中)

Sublime Text自定制代码片段(Code Snippets)

Kibana深入 | Timelion画图实现系统监控

几条jQuery代码片段助力Web开发效率提升

XMLéè | 同色系搭配 开启你的奇妙物语