FixedBucketSampler(一)_match_bucket_keys

import numpy as np
def _match_bucket_keys(bucket_keys, seq_lengths):
    """

    :param bucket_keys: 每个区间的右侧值。
    :param seq_lengths: 序列长度列表,存每个句子的长度的列表。
    :return: 每个区间存放的样本id值,便于取出来
    """
    bucket_key_npy = np.array(bucket_keys, dtype=np.int32)
    bucket_sample_ids = [list() for _ in range(len(bucket_keys))]
    batch_size = 10000
    bucket_key_npy = bucket_key_npy.reshape((1,) + bucket_key_npy.shape)
    for begin in range(0, len(seq_lengths), batch_size):
        end = min(begin + batch_size, len(seq_lengths))
        diff = bucket_key_npy - np.expand_dims(seq_lengths[begin:end], axis=1) #通过广播机制来求序列长度落在哪一个区间的核心代码
        if diff.ndim == 3:
            is_valid_bucket = np.prod(diff >= 0, axis=2) #最后一个维度同时满足的情况下是在哪一个区间,即针对2组数满足落在(临界的)两组区间上才为1
            pad_val = np.sum(diff, axis=2)
        else:
            is_valid_bucket = diff >= 0
            pad_val = diff
        seq_ids_not_found = np.nonzero(is_valid_bucket.sum(axis=1) == 0)[0].tolist()
        masked_pad_val = np.ma.array(pad_val, mask=1 - is_valid_bucket) #对数组中的掩码(缺失值)的处理
        batch_bucket_id = masked_pad_val.argmin(axis=1).tolist() #获取数组最小值的索引列表
        if len(seq_ids_not_found) > 0:
            raise ValueError('Find elements in seq_lengths that cannot fit in the '
                             'given buckets, seq_length=%s, bucket_keys=%s. ' \
                             'You must increase the bucket size.'
                             % (str(seq_lengths[seq_ids_not_found]), str(bucket_keys)))
        for i, bucket_id in enumerate(batch_bucket_id):
            bucket_sample_ids[bucket_id].append(i + begin)
    return bucket_sample_ids

if __name__ == '__main__':

    lengths = [np.random.randint(1, 100) for _ in range(1000)] #针对单组长度不一的数据进行抽样,让长度相近的句子放在一起
    print('single lengths: ', lengths)
    bucket_keys = range(10,100+10,10)
    print('single result: ', _match_bucket_keys(bucket_keys, lengths))

    pair_lengths = [(l, l-1) for l in lengths] #针对两组长度不一的数据进行抽样(例如应用在机器翻译中)
    pair_bucket_keys = [(i,i) for i in bucket_keys]
    print('pair lengths: ', pair_lengths)
    print('pair result: ',_match_bucket_keys(pair_bucket_keys, pair_lengths))

结果:

single lengths:  [90, 86, 5, 88, 98, 13, 21, 55, 44, 33, 2, 48, 61, 84, 88, 83, 89, 32, 45, 60, 14, 63, 20, 30, 25, 80, 92, 28, 7, 54, 30, 93, 88, 65, 30, 8, 75, 92, 60, 54, 44, 10, 16, 6, 35, 57, 57, 73, 32, 23, 98, 75, 92, 27, 10, 54, 26, 97, 50, 15, 91, 35, 3, 64, 36, 60, 86, 1, 76, 98, 73, 9, 40, 32, 79, 46, 86, 72, 1, 96, 41, 83, 6, 95, 79, 82, 9, 23, 80, 39, 89, 83, 37, 13, 66, 71, 15, 12, 57, 79, 49, 81, 63, 57, 87, 31, 29, 35, 18, 9, 15, 97, 11, 5, 66, 73, 58, 52, 27, 52, 73, 69, 78, 53, 24, 81, 69, 75, 75, 72, 56, 22, 97, 49, 50, 73, 37, 84, 53, 80, 49, 84, 89, 78, 46, 93, 99, 69, 80, 70, 13, 9, 50, 54, 86, 13, 54, 7, 50, 24, 16, 37, 95, 27, 60, 73, 51, 71, 98, 37, 94, 10, 80, 72, 11, 88, 30, 78, 69, 49, 47, 2, 44, 9, 2, 36, 15, 81, 48, 24, 89, 22, 7, 45, 46, 7, 2, 28, 84, 45, 91, 86, 87, 87, 52, 95, 3, 87, 81, 53, 83, 19, 89, 74, 72, 61, 74, 63, 76, 6, 96, 95, 98, 65, 1, 98, 92, 26, 97, 73, 67, 73, 56, 32, 66, 89, 96, 13, 15, 11, 85, 62, 44, 83, 1, 84, 39, 1, 32, 23, 70, 71, 28, 76, 16, 71, 71, 64, 90, 38, 43, 60, 34, 72, 57, 81, 59, 53, 23, 27, 46, 87, 24, 81, 5, 75, 74, 44, 70, 58, 21, 88, 16, 78, 3, 83, 52, 78, 97, 82, 2, 96, 56, 92, 62, 27, 8, 16, 21, 78, 31, 64, 46, 73, 48, 13, 7, 24, 38, 21, 40, 24, 53, 54, 59, 70, 30, 37, 28, 86, 65, 57, 5, 97, 55, 15, 43, 19, 61, 76, 45, 58, 60, 51, 14, 12, 3, 77, 50, 60, 30, 96, 1, 17, 42, 29, 45, 55, 5, 27, 70, 56, 91, 7, 89, 59, 36, 79, 8, 20, 8, 60, 70, 62, 29, 99, 14, 33, 33, 36, 36, 9, 20, 40, 77, 68, 73, 56, 9, 69, 50, 58, 74, 88, 26, 24, 94, 19, 68, 46, 64, 31, 31, 48, 33, 3, 76, 83, 39, 6, 66, 38, 7, 63, 7, 88, 65, 23, 66, 73, 57, 79, 40, 71, 11, 74, 64, 38, 34, 74, 50, 98, 83, 98, 58, 26, 13, 18, 39, 44, 3, 40, 19, 21, 18, 79, 21, 44, 51, 65, 30, 46, 9, 71, 20, 10, 27, 34, 33, 46, 62, 44, 36, 73, 66, 31, 38, 75, 27, 12, 56, 98, 73, 97, 50, 45, 66, 83, 15, 59, 98, 89, 56, 23, 54, 2, 55, 75, 20, 81, 25, 72, 65, 19, 90, 71, 4, 84, 6, 74, 42, 9, 54, 75, 64, 53, 57, 33, 3, 13, 85, 56, 20, 54, 15, 98, 31, 81, 55, 82, 61, 94, 45, 43, 62, 24, 99, 83, 31, 17, 26, 25, 58, 36, 50, 1, 54, 33, 73, 17, 59, 90, 42, 67, 14, 59, 89, 67, 92, 88, 78, 33, 82, 23, 95, 93, 14, 59, 51, 7, 42, 31, 3, 69, 9, 57, 73, 8, 76, 55, 85, 67, 49, 55, 18, 21, 43, 15, 4, 41, 27, 20, 38, 35, 13, 9, 26, 96, 22, 30, 70, 96, 85, 35, 47, 26, 38, 57, 61, 20, 37, 18, 77, 62, 44, 78, 51, 95, 73, 90, 44, 18, 44, 85, 11, 74, 56, 84, 67, 64, 39, 96, 39, 66, 45, 96, 53, 26, 2, 15, 73, 37, 72, 15, 47, 54, 11, 18, 14, 34, 70, 38, 11, 43, 1, 93, 88, 92, 79, 75, 69, 87, 79, 6, 18, 2, 95, 69, 52, 98, 3, 27, 17, 50, 42, 2, 27, 57, 4, 47, 57, 69, 43, 83, 42, 67, 22, 55, 93, 88, 76, 93, 22, 76, 46, 42, 95, 6, 20, 99, 70, 71, 68, 93, 46, 48, 70, 8, 21, 67, 4, 42, 62, 91, 80, 57, 81, 12, 85, 30, 79, 13, 64, 80, 32, 67, 32, 91, 29, 43, 56, 32, 91, 44, 53, 98, 10, 66, 54, 73, 46, 23, 80, 54, 43, 53, 75, 74, 20, 7, 66, 85, 38, 26, 21, 60, 41, 81, 21, 50, 46, 54, 38, 50, 64, 27, 28, 75, 57, 70, 43, 53, 68, 87, 74, 23, 38, 84, 39, 40, 35, 61, 42, 69, 95, 41, 70, 42, 27, 28, 80, 91, 57, 48, 40, 31, 62, 27, 54, 90, 87, 93, 81, 25, 94, 82, 80, 48, 6, 88, 34, 84, 58, 96, 82, 86, 6, 18, 4, 80, 37, 13, 50, 87, 23, 27, 92, 29, 41, 65, 54, 85, 67, 61, 58, 64, 50, 63, 84, 61, 17, 17, 89, 87, 9, 12, 87, 48, 14, 73, 6, 43, 82, 39, 31, 88, 22, 22, 37, 52, 25, 29, 52, 1, 2, 65, 4, 44, 49, 97, 95, 15, 2, 40, 74, 40, 41, 26, 77, 51, 58, 50, 96, 65, 87, 76, 80, 44, 93, 60, 55, 46, 3, 14, 16, 13, 72, 82, 30, 86, 88, 31, 7, 51, 65, 8, 69, 67, 55, 2, 59, 97, 38, 75, 97, 25, 4, 81, 98, 53, 37, 23, 52, 23, 89, 92, 34, 21, 50, 35, 41, 90, 15, 92, 18, 96, 97, 56, 22, 31, 26, 12, 81, 69, 15, 36, 36, 78, 51, 56, 72, 94, 33, 93, 33, 94, 50, 7, 27, 97, 69, 93, 30, 93, 25, 18, 8, 54, 81, 32, 49, 68, 57, 84, 14, 28, 78, 45, 80, 91, 8, 41, 90, 80, 48, 20, 90, 31, 69, 25, 14, 50, 83, 57, 42, 74, 69, 39, 14, 11, 85, 30, 63, 92, 77, 1, 14, 80, 37, 10, 25, 99, 54, 33, 87, 95, 49, 59, 29, 71]
single result:  [[2, 10, 28, 35, 41, 43, 54, 62, 67, 71, 78, 82, 86, 109, 113, 151, 157, 171, 181, 183, 184, 192, 195, 196, 206, 219, 224, 244, 247, 274, 284, 290, 296, 306, 322, 336, 342, 348, 353, 358, 360, 371, 378, 395, 399, 402, 404, 430, 442, 445, 475, 486, 488, 491, 498, 525, 549, 552, 554, 557, 568, 575, 618, 634, 643, 645, 650, 655, 658, 677, 687, 690, 716, 729, 788, 796, 798, 824, 830, 843, 844, 846, 852, 872, 882, 885, 889, 896, 937, 946, 960, 985, 989], [5, 20, 22, 42, 59, 93, 96, 97, 108, 110, 112, 150, 155, 160, 174, 186, 211, 237, 238, 239, 254, 282, 297, 305, 325, 327, 334, 335, 343, 359, 366, 372, 387, 414, 426, 427, 432, 434, 444, 459, 468, 478, 483, 499, 502, 504, 519, 529, 534, 546, 564, 567, 571, 574, 589, 591, 601, 604, 619, 623, 626, 627, 628, 632, 644, 652, 678, 697, 701, 728, 797, 801, 820, 821, 825, 828, 851, 873, 874, 875, 912, 914, 921, 924, 945, 954, 965, 970, 978, 979, 986], [6, 23, 24, 27, 30, 34, 49, 53, 56, 87, 106, 118, 124, 131, 159, 163, 176, 189, 191, 197, 227, 249, 252, 268, 269, 272, 280, 295, 298, 307, 309, 311, 316, 318, 340, 345, 349, 364, 384, 385, 407, 425, 433, 436, 440, 446, 458, 473, 480, 515, 520, 521, 543, 565, 570, 576, 578, 579, 585, 617, 651, 656, 666, 672, 688, 699, 708, 721, 733, 734, 738, 745, 746, 755, 768, 769, 777, 783, 804, 805, 807, 836, 837, 840, 841, 857, 878, 895, 901, 903, 907, 918, 920, 938, 942, 944, 955, 969, 981, 990, 998], [9, 17, 44, 48, 61, 64, 72, 73, 89, 92, 105, 107, 136, 161, 169, 185, 233, 246, 248, 259, 262, 300, 308, 310, 317, 356, 367, 368, 369, 370, 373, 391, 392, 394, 398, 401, 412, 417, 418, 428, 431, 447, 448, 452, 455, 456, 497, 506, 518, 523, 527, 541, 551, 572, 573, 583, 586, 590, 610, 612, 621, 629, 631, 704, 706, 711, 732, 742, 756, 758, 759, 760, 774, 775, 790, 800, 833, 834, 838, 853, 855, 881, 892, 900, 906, 909, 919, 925, 926, 932, 934, 949, 967, 977, 988, 993], [8, 11, 18, 40, 58, 75, 80, 100, 133, 134, 140, 144, 152, 158, 179, 180, 182, 188, 193, 194, 199, 242, 260, 270, 277, 302, 304, 326, 330, 338, 344, 346, 380, 389, 393, 420, 429, 437, 441, 449, 451, 464, 465, 490, 512, 513, 524, 532, 550, 562, 566, 569, 584, 594, 600, 602, 614, 624, 633, 653, 654, 659, 662, 664, 674, 675, 684, 685, 691, 709, 713, 720, 724, 736, 739, 740, 743, 750, 762, 765, 767, 773, 787, 802, 808, 816, 827, 831, 847, 848, 856, 861, 867, 871, 908, 910, 936, 950, 957, 961, 964, 971, 974, 996], [7, 19, 29, 38, 39, 45, 46, 55, 65, 98, 103, 116, 117, 119, 123, 130, 138, 153, 156, 164, 166, 204, 209, 232, 261, 264, 266, 267, 279, 286, 292, 312, 313, 314, 321, 324, 331, 332, 333, 339, 347, 351, 355, 361, 377, 381, 410, 424, 438, 460, 469, 472, 474, 476, 492, 495, 496, 501, 503, 508, 522, 526, 530, 535, 547, 548, 555, 559, 563, 587, 596, 606, 616, 625, 648, 657, 660, 667, 695, 710, 714, 718, 723, 725, 735, 741, 748, 751, 772, 778, 792, 810, 814, 839, 842, 859, 860, 869, 870, 883, 888, 890, 899, 902, 917, 928, 929, 947, 952, 973, 992, 997], [12, 21, 33, 63, 94, 102, 114, 121, 126, 147, 149, 178, 215, 217, 223, 230, 234, 241, 250, 257, 278, 294, 301, 315, 320, 328, 350, 362, 363, 375, 379, 388, 390, 400, 403, 406, 408, 416, 439, 450, 454, 466, 482, 494, 510, 514, 533, 537, 553, 561, 580, 588, 593, 608, 609, 613, 630, 640, 647, 661, 665, 680, 682, 686, 689, 692, 702, 705, 717, 730, 744, 749, 752, 761, 763, 766, 776, 809, 812, 813, 815, 817, 819, 845, 863, 884, 886, 887, 923, 940, 951, 968, 976, 982], [25, 36, 47, 51, 68, 70, 74, 77, 84, 88, 95, 99, 115, 120, 122, 127, 128, 129, 135, 139, 143, 148, 165, 167, 172, 173, 177, 213, 214, 216, 218, 229, 231, 251, 253, 255, 256, 263, 275, 276, 283, 287, 299, 303, 329, 337, 357, 374, 376, 382, 396, 409, 411, 413, 415, 419, 435, 443, 453, 457, 462, 477, 481, 485, 489, 493, 528, 540, 556, 558, 592, 595, 598, 605, 620, 622, 638, 639, 642, 670, 673, 681, 694, 700, 703, 719, 722, 726, 727, 747, 754, 770, 786, 799, 829, 854, 858, 865, 866, 876, 893, 927, 930, 956, 958, 963, 975, 984, 987, 999], [0, 1, 3, 13, 14, 15, 16, 32, 66, 76, 81, 85, 90, 91, 101, 104, 125, 137, 141, 142, 154, 175, 187, 190, 198, 201, 202, 203, 207, 208, 210, 212, 235, 240, 243, 245, 258, 265, 271, 273, 281, 285, 289, 319, 354, 383, 397, 405, 422, 467, 471, 479, 484, 487, 500, 507, 509, 517, 531, 536, 539, 542, 560, 582, 599, 603, 607, 636, 641, 663, 669, 696, 698, 731, 737, 753, 757, 779, 780, 782, 785, 789, 791, 794, 795, 803, 811, 818, 822, 823, 826, 832, 835, 864, 877, 879, 880, 897, 904, 911, 922, 948, 953, 962, 966, 972, 980, 994], [4, 26, 31, 37, 50, 52, 57, 60, 69, 79, 83, 111, 132, 145, 146, 162, 168, 170, 200, 205, 220, 221, 222, 225, 226, 228, 236, 288, 291, 293, 323, 341, 352, 365, 386, 421, 423, 461, 463, 470, 505, 511, 516, 538, 544, 545, 577, 581, 597, 611, 615, 635, 637, 646, 649, 668, 671, 676, 679, 683, 693, 707, 712, 715, 764, 771, 781, 784, 793, 806, 849, 850, 862, 868, 891, 894, 898, 905, 913, 915, 916, 931, 933, 935, 939, 941, 943, 959, 983, 991, 995]]
pair lengths:  [(90, 89), (86, 85), (5, 4), (88, 87), (98, 97), (13, 12), (21, 20), (55, 54), (44, 43), (33, 32), (2, 1), (48, 47), (61, 60), (84, 83), (88, 87), (83, 82), (89, 88), (32, 31), (45, 44), (60, 59), (14, 13), (63, 62), (20, 19), (30, 29), (25, 24), (80, 79), (92, 91), (28, 27), (7, 6), (54, 53), (30, 29), (93, 92), (88, 87), (65, 64), (30, 29), (8, 7), (75, 74), (92, 91), (60, 59), (54, 53), (44, 43), (10, 9), (16, 15), (6, 5), (35, 34), (57, 56), (57, 56), (73, 72), (32, 31), (23, 22), (98, 97), (75, 74), (92, 91), (27, 26), (10, 9), (54, 53), (26, 25), (97, 96), (50, 49), (15, 14), (91, 90), (35, 34), (3, 2), (64, 63), (36, 35), (60, 59), (86, 85), (1, 0), (76, 75), (98, 97), (73, 72), (9, 8), (40, 39), (32, 31), (79, 78), (46, 45), (86, 85), (72, 71), (1, 0), (96, 95), (41, 40), (83, 82), (6, 5), (95, 94), (79, 78), (82, 81), (9, 8), (23, 22), (80, 79), (39, 38), (89, 88), (83, 82), (37, 36), (13, 12), (66, 65), (71, 70), (15, 14), (12, 11), (57, 56), (79, 78), (49, 48), (81, 80), (63, 62), (57, 56), (87, 86), (31, 30), (29, 28), (35, 34), (18, 17), (9, 8), (15, 14), (97, 96), (11, 10), (5, 4), (66, 65), (73, 72), (58, 57), (52, 51), (27, 26), (52, 51), (73, 72), (69, 68), (78, 77), (53, 52), (24, 23), (81, 80), (69, 68), (75, 74), (75, 74), (72, 71), (56, 55), (22, 21), (97, 96), (49, 48), (50, 49), (73, 72), (37, 36), (84, 83), (53, 52), (80, 79), (49, 48), (84, 83), (89, 88), (78, 77), (46, 45), (93, 92), (99, 98), (69, 68), (80, 79), (70, 69), (13, 12), (9, 8), (50, 49), (54, 53), (86, 85), (13, 12), (54, 53), (7, 6), (50, 49), (24, 23), (16, 15), (37, 36), (95, 94), (27, 26), (60, 59), (73, 72), (51, 50), (71, 70), (98, 97), (37, 36), (94, 93), (10, 9), (80, 79), (72, 71), (11, 10), (88, 87), (30, 29), (78, 77), (69, 68), (49, 48), (47, 46), (2, 1), (44, 43), (9, 8), (2, 1), (36, 35), (15, 14), (81, 80), (48, 47), (24, 23), (89, 88), (22, 21), (7, 6), (45, 44), (46, 45), (7, 6), (2, 1), (28, 27), (84, 83), (45, 44), (91, 90), (86, 85), (87, 86), (87, 86), (52, 51), (95, 94), (3, 2), (87, 86), (81, 80), (53, 52), (83, 82), (19, 18), (89, 88), (74, 73), (72, 71), (61, 60), (74, 73), (63, 62), (76, 75), (6, 5), (96, 95), (95, 94), (98, 97), (65, 64), (1, 0), (98, 97), (92, 91), (26, 25), (97, 96), (73, 72), (67, 66), (73, 72), (56, 55), (32, 31), (66, 65), (89, 88), (96, 95), (13, 12), (15, 14), (11, 10), (85, 84), (62, 61), (44, 43), (83, 82), (1, 0), (84, 83), (39, 38), (1, 0), (32, 31), (23, 22), (70, 69), (71, 70), (28, 27), (76, 75), (16, 15), (71, 70), (71, 70), (64, 63), (90, 89), (38, 37), (43, 42), (60, 59), (34, 33), (72, 71), (57, 56), (81, 80), (59, 58), (53, 52), (23, 22), (27, 26), (46, 45), (87, 86), (24, 23), (81, 80), (5, 4), (75, 74), (74, 73), (44, 43), (70, 69), (58, 57), (21, 20), (88, 87), (16, 15), (78, 77), (3, 2), (83, 82), (52, 51), (78, 77), (97, 96), (82, 81), (2, 1), (96, 95), (56, 55), (92, 91), (62, 61), (27, 26), (8, 7), (16, 15), (21, 20), (78, 77), (31, 30), (64, 63), (46, 45), (73, 72), (48, 47), (13, 12), (7, 6), (24, 23), (38, 37), (21, 20), (40, 39), (24, 23), (53, 52), (54, 53), (59, 58), (70, 69), (30, 29), (37, 36), (28, 27), (86, 85), (65, 64), (57, 56), (5, 4), (97, 96), (55, 54), (15, 14), (43, 42), (19, 18), (61, 60), (76, 75), (45, 44), (58, 57), (60, 59), (51, 50), (14, 13), (12, 11), (3, 2), (77, 76), (50, 49), (60, 59), (30, 29), (96, 95), (1, 0), (17, 16), (42, 41), (29, 28), (45, 44), (55, 54), (5, 4), (27, 26), (70, 69), (56, 55), (91, 90), (7, 6), (89, 88), (59, 58), (36, 35), (79, 78), (8, 7), (20, 19), (8, 7), (60, 59), (70, 69), (62, 61), (29, 28), (99, 98), (14, 13), (33, 32), (33, 32), (36, 35), (36, 35), (9, 8), (20, 19), (40, 39), (77, 76), (68, 67), (73, 72), (56, 55), (9, 8), (69, 68), (50, 49), (58, 57), (74, 73), (88, 87), (26, 25), (24, 23), (94, 93), (19, 18), (68, 67), (46, 45), (64, 63), (31, 30), (31, 30), (48, 47), (33, 32), (3, 2), (76, 75), (83, 82), (39, 38), (6, 5), (66, 65), (38, 37), (7, 6), (63, 62), (7, 6), (88, 87), (65, 64), (23, 22), (66, 65), (73, 72), (57, 56), (79, 78), (40, 39), (71, 70), (11, 10), (74, 73), (64, 63), (38, 37), (34, 33), (74, 73), (50, 49), (98, 97), (83, 82), (98, 97), (58, 57), (26, 25), (13, 12), (18, 17), (39, 38), (44, 43), (3, 2), (40, 39), (19, 18), (21, 20), (18, 17), (79, 78), (21, 20), (44, 43), (51, 50), (65, 64), (30, 29), (46, 45), (9, 8), (71, 70), (20, 19), (10, 9), (27, 26), (34, 33), (33, 32), (46, 45), (62, 61), (44, 43), (36, 35), (73, 72), (66, 65), (31, 30), (38, 37), (75, 74), (27, 26), (12, 11), (56, 55), (98, 97), (73, 72), (97, 96), (50, 49), (45, 44), (66, 65), (83, 82), (15, 14), (59, 58), (98, 97), (89, 88), (56, 55), (23, 22), (54, 53), (2, 1), (55, 54), (75, 74), (20, 19), (81, 80), (25, 24), (72, 71), (65, 64), (19, 18), (90, 89), (71, 70), (4, 3), (84, 83), (6, 5), (74, 73), (42, 41), (9, 8), (54, 53), (75, 74), (64, 63), (53, 52), (57, 56), (33, 32), (3, 2), (13, 12), (85, 84), (56, 55), (20, 19), (54, 53), (15, 14), (98, 97), (31, 30), (81, 80), (55, 54), (82, 81), (61, 60), (94, 93), (45, 44), (43, 42), (62, 61), (24, 23), (99, 98), (83, 82), (31, 30), (17, 16), (26, 25), (25, 24), (58, 57), (36, 35), (50, 49), (1, 0), (54, 53), (33, 32), (73, 72), (17, 16), (59, 58), (90, 89), (42, 41), (67, 66), (14, 13), (59, 58), (89, 88), (67, 66), (92, 91), (88, 87), (78, 77), (33, 32), (82, 81), (23, 22), (95, 94), (93, 92), (14, 13), (59, 58), (51, 50), (7, 6), (42, 41), (31, 30), (3, 2), (69, 68), (9, 8), (57, 56), (73, 72), (8, 7), (76, 75), (55, 54), (85, 84), (67, 66), (49, 48), (55, 54), (18, 17), (21, 20), (43, 42), (15, 14), (4, 3), (41, 40), (27, 26), (20, 19), (38, 37), (35, 34), (13, 12), (9, 8), (26, 25), (96, 95), (22, 21), (30, 29), (70, 69), (96, 95), (85, 84), (35, 34), (47, 46), (26, 25), (38, 37), (57, 56), (61, 60), (20, 19), (37, 36), (18, 17), (77, 76), (62, 61), (44, 43), (78, 77), (51, 50), (95, 94), (73, 72), (90, 89), (44, 43), (18, 17), (44, 43), (85, 84), (11, 10), (74, 73), (56, 55), (84, 83), (67, 66), (64, 63), (39, 38), (96, 95), (39, 38), (66, 65), (45, 44), (96, 95), (53, 52), (26, 25), (2, 1), (15, 14), (73, 72), (37, 36), (72, 71), (15, 14), (47, 46), (54, 53), (11, 10), (18, 17), (14, 13), (34, 33), (70, 69), (38, 37), (11, 10), (43, 42), (1, 0), (93, 92), (88, 87), (92, 91), (79, 78), (75, 74), (69, 68), (87, 86), (79, 78), (6, 5), (18, 17), (2, 1), (95, 94), (69, 68), (52, 51), (98, 97), (3, 2), (27, 26), (17, 16), (50, 49), (42, 41), (2, 1), (27, 26), (57, 56), (4, 3), (47, 46), (57, 56), (69, 68), (43, 42), (83, 82), (42, 41), (67, 66), (22, 21), (55, 54), (93, 92), (88, 87), (76, 75), (93, 92), (22, 21), (76, 75), (46, 45), (42, 41), (95, 94), (6, 5), (20, 19), (99, 98), (70, 69), (71, 70), (68, 67), (93, 92), (46, 45), (48, 47), (70, 69), (8, 7), (21, 20), (67, 66), (4, 3), (42, 41), (62, 61), (91, 90), (80, 79), (57, 56), (81, 80), (12, 11), (85, 84), (30, 29), (79, 78), (13, 12), (64, 63), (80, 79), (32, 31), (67, 66), (32, 31), (91, 90), (29, 28), (43, 42), (56, 55), (32, 31), (91, 90), (44, 43), (53, 52), (98, 97), (10, 9), (66, 65), (54, 53), (73, 72), (46, 45), (23, 22), (80, 79), (54, 53), (43, 42), (53, 52), (75, 74), (74, 73), (20, 19), (7, 6), (66, 65), (85, 84), (38, 37), (26, 25), (21, 20), (60, 59), (41, 40), (81, 80), (21, 20), (50, 49), (46, 45), (54, 53), (38, 37), (50, 49), (64, 63), (27, 26), (28, 27), (75, 74), (57, 56), (70, 69), (43, 42), (53, 52), (68, 67), (87, 86), (74, 73), (23, 22), (38, 37), (84, 83), (39, 38), (40, 39), (35, 34), (61, 60), (42, 41), (69, 68), (95, 94), (41, 40), (70, 69), (42, 41), (27, 26), (28, 27), (80, 79), (91, 90), (57, 56), (48, 47), (40, 39), (31, 30), (62, 61), (27, 26), (54, 53), (90, 89), (87, 86), (93, 92), (81, 80), (25, 24), (94, 93), (82, 81), (80, 79), (48, 47), (6, 5), (88, 87), (34, 33), (84, 83), (58, 57), (96, 95), (82, 81), (86, 85), (6, 5), (18, 17), (4, 3), (80, 79), (37, 36), (13, 12), (50, 49), (87, 86), (23, 22), (27, 26), (92, 91), (29, 28), (41, 40), (65, 64), (54, 53), (85, 84), (67, 66), (61, 60), (58, 57), (64, 63), (50, 49), (63, 62), (84, 83), (61, 60), (17, 16), (17, 16), (89, 88), (87, 86), (9, 8), (12, 11), (87, 86), (48, 47), (14, 13), (73, 72), (6, 5), (43, 42), (82, 81), (39, 38), (31, 30), (88, 87), (22, 21), (22, 21), (37, 36), (52, 51), (25, 24), (29, 28), (52, 51), (1, 0), (2, 1), (65, 64), (4, 3), (44, 43), (49, 48), (97, 96), (95, 94), (15, 14), (2, 1), (40, 39), (74, 73), (40, 39), (41, 40), (26, 25), (77, 76), (51, 50), (58, 57), (50, 49), (96, 95), (65, 64), (87, 86), (76, 75), (80, 79), (44, 43), (93, 92), (60, 59), (55, 54), (46, 45), (3, 2), (14, 13), (16, 15), (13, 12), (72, 71), (82, 81), (30, 29), (86, 85), (88, 87), (31, 30), (7, 6), (51, 50), (65, 64), (8, 7), (69, 68), (67, 66), (55, 54), (2, 1), (59, 58), (97, 96), (38, 37), (75, 74), (97, 96), (25, 24), (4, 3), (81, 80), (98, 97), (53, 52), (37, 36), (23, 22), (52, 51), (23, 22), (89, 88), (92, 91), (34, 33), (21, 20), (50, 49), (35, 34), (41, 40), (90, 89), (15, 14), (92, 91), (18, 17), (96, 95), (97, 96), (56, 55), (22, 21), (31, 30), (26, 25), (12, 11), (81, 80), (69, 68), (15, 14), (36, 35), (36, 35), (78, 77), (51, 50), (56, 55), (72, 71), (94, 93), (33, 32), (93, 92), (33, 32), (94, 93), (50, 49), (7, 6), (27, 26), (97, 96), (69, 68), (93, 92), (30, 29), (93, 92), (25, 24), (18, 17), (8, 7), (54, 53), (81, 80), (32, 31), (49, 48), (68, 67), (57, 56), (84, 83), (14, 13), (28, 27), (78, 77), (45, 44), (80, 79), (91, 90), (8, 7), (41, 40), (90, 89), (80, 79), (48, 47), (20, 19), (90, 89), (31, 30), (69, 68), (25, 24), (14, 13), (50, 49), (83, 82), (57, 56), (42, 41), (74, 73), (69, 68), (39, 38), (14, 13), (11, 10), (85, 84), (30, 29), (63, 62), (92, 91), (77, 76), (1, 0), (14, 13), (80, 79), (37, 36), (10, 9), (25, 24), (99, 98), (54, 53), (33, 32), (87, 86), (95, 94), (49, 48), (59, 58), (29, 28), (71, 70)]
pair result:  [[2, 10, 28, 35, 41, 43, 54, 62, 67, 71, 78, 82, 86, 109, 113, 151, 157, 171, 181, 183, 184, 192, 195, 196, 206, 219, 224, 244, 247, 274, 284, 290, 296, 306, 322, 336, 342, 348, 353, 358, 360, 371, 378, 395, 399, 402, 404, 430, 442, 445, 475, 486, 488, 491, 498, 525, 549, 552, 554, 557, 568, 575, 618, 634, 643, 645, 650, 655, 658, 677, 687, 690, 716, 729, 788, 796, 798, 824, 830, 843, 844, 846, 852, 872, 882, 885, 889, 896, 937, 946, 960, 985, 989], [5, 20, 22, 42, 59, 93, 96, 97, 108, 110, 112, 150, 155, 160, 174, 186, 211, 237, 238, 239, 254, 282, 297, 305, 325, 327, 334, 335, 343, 359, 366, 372, 387, 414, 426, 427, 432, 434, 444, 459, 468, 478, 483, 499, 502, 504, 519, 529, 534, 546, 564, 567, 571, 574, 589, 591, 601, 604, 619, 623, 626, 627, 628, 632, 644, 652, 678, 697, 701, 728, 797, 801, 820, 821, 825, 828, 851, 873, 874, 875, 912, 914, 921, 924, 945, 954, 965, 970, 978, 979, 986], [6, 23, 24, 27, 30, 34, 49, 53, 56, 87, 106, 118, 124, 131, 159, 163, 176, 189, 191, 197, 227, 249, 252, 268, 269, 272, 280, 295, 298, 307, 309, 311, 316, 318, 340, 345, 349, 364, 384, 385, 407, 425, 433, 436, 440, 446, 458, 473, 480, 515, 520, 521, 543, 565, 570, 576, 578, 579, 585, 617, 651, 656, 666, 672, 688, 699, 708, 721, 733, 734, 738, 745, 746, 755, 768, 769, 777, 783, 804, 805, 807, 836, 837, 840, 841, 857, 878, 895, 901, 903, 907, 918, 920, 938, 942, 944, 955, 969, 981, 990, 998], [9, 17, 44, 48, 61, 64, 72, 73, 89, 92, 105, 107, 136, 161, 169, 185, 233, 246, 248, 259, 262, 300, 308, 310, 317, 356, 367, 368, 369, 370, 373, 391, 392, 394, 398, 401, 412, 417, 418, 428, 431, 447, 448, 452, 455, 456, 497, 506, 518, 523, 527, 541, 551, 572, 573, 583, 586, 590, 610, 612, 621, 629, 631, 704, 706, 711, 732, 742, 756, 758, 759, 760, 774, 775, 790, 800, 833, 834, 838, 853, 855, 881, 892, 900, 906, 909, 919, 925, 926, 932, 934, 949, 967, 977, 988, 993], [8, 11, 18, 40, 58, 75, 80, 100, 133, 134, 140, 144, 152, 158, 179, 180, 182, 188, 193, 194, 199, 242, 260, 270, 277, 302, 304, 326, 330, 338, 344, 346, 380, 389, 393, 420, 429, 437, 441, 449, 451, 464, 465, 490, 512, 513, 524, 532, 550, 562, 566, 569, 584, 594, 600, 602, 614, 624, 633, 653, 654, 659, 662, 664, 674, 675, 684, 685, 691, 709, 713, 720, 724, 736, 739, 740, 743, 750, 762, 765, 767, 773, 787, 802, 808, 816, 827, 831, 847, 848, 856, 861, 867, 871, 908, 910, 936, 950, 957, 961, 964, 971, 974, 996], [7, 19, 29, 38, 39, 45, 46, 55, 65, 98, 103, 116, 117, 119, 123, 130, 138, 153, 156, 164, 166, 204, 209, 232, 261, 264, 266, 267, 279, 286, 292, 312, 313, 314, 321, 324, 331, 332, 333, 339, 347, 351, 355, 361, 377, 381, 410, 424, 438, 460, 469, 472, 474, 476, 492, 495, 496, 501, 503, 508, 522, 526, 530, 535, 547, 548, 555, 559, 563, 587, 596, 606, 616, 625, 648, 657, 660, 667, 695, 710, 714, 718, 723, 725, 735, 741, 748, 751, 772, 778, 792, 810, 814, 839, 842, 859, 860, 869, 870, 883, 888, 890, 899, 902, 917, 928, 929, 947, 952, 973, 992, 997], [12, 21, 33, 63, 94, 102, 114, 121, 126, 147, 149, 178, 215, 217, 223, 230, 234, 241, 250, 257, 278, 294, 301, 315, 320, 328, 350, 362, 363, 375, 379, 388, 390, 400, 403, 406, 408, 416, 439, 450, 454, 466, 482, 494, 510, 514, 533, 537, 553, 561, 580, 588, 593, 608, 609, 613, 630, 640, 647, 661, 665, 680, 682, 686, 689, 692, 702, 705, 717, 730, 744, 749, 752, 761, 763, 766, 776, 809, 812, 813, 815, 817, 819, 845, 863, 884, 886, 887, 923, 940, 951, 968, 976, 982], [25, 36, 47, 51, 68, 70, 74, 77, 84, 88, 95, 99, 115, 120, 122, 127, 128, 129, 135, 139, 143, 148, 165, 167, 172, 173, 177, 213, 214, 216, 218, 229, 231, 251, 253, 255, 256, 263, 275, 276, 283, 287, 299, 303, 329, 337, 357, 374, 376, 382, 396, 409, 411, 413, 415, 419, 435, 443, 453, 457, 462, 477, 481, 485, 489, 493, 528, 540, 556, 558, 592, 595, 598, 605, 620, 622, 638, 639, 642, 670, 673, 681, 694, 700, 703, 719, 722, 726, 727, 747, 754, 770, 786, 799, 829, 854, 858, 865, 866, 876, 893, 927, 930, 956, 958, 963, 975, 984, 987, 999], [0, 1, 3, 13, 14, 15, 16, 32, 66, 76, 81, 85, 90, 91, 101, 104, 125, 137, 141, 142, 154, 175, 187, 190, 198, 201, 202, 203, 207, 208, 210, 212, 235, 240, 243, 245, 258, 265, 271, 273, 281, 285, 289, 319, 354, 383, 397, 405, 422, 467, 471, 479, 484, 487, 500, 507, 509, 517, 531, 536, 539, 542, 560, 582, 599, 603, 607, 636, 641, 663, 669, 696, 698, 731, 737, 753, 757, 779, 780, 782, 785, 789, 791, 794, 795, 803, 811, 818, 822, 823, 826, 832, 835, 864, 877, 879, 880, 897, 904, 911, 922, 948, 953, 962, 966, 972, 980, 994], [4, 26, 31, 37, 50, 52, 57, 60, 69, 79, 83, 111, 132, 145, 146, 162, 168, 170, 200, 205, 220, 221, 222, 225, 226, 228, 236, 288, 291, 293, 323, 341, 352, 365, 386, 421, 423, 461, 463, 470, 505, 511, 516, 538, 544, 545, 577, 581, 597, 611, 615, 635, 637, 646, 649, 668, 671, 676, 679, 683, 693, 707, 712, 715, 764, 771, 781, 784, 793, 806, 849, 850, 862, 868, 891, 894, 898, 905, 913, 915, 916, 931, 933, 935, 939, 941, 943, 959, 983, 991, 995]]
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值