2017-10-01 12:13

Shift By 7

  • equals
  • numbers
  • 函数
  • hash
  • each

Given a hash table of size N with M (<= N) positive integers in. If these integers were inserted into the table according to the hash function h(x)=(x+7)%N, and if linear probing (with a step size equals to one) was used to solve collisions. Please output a possible sequence of insertions.

Note: when there were more than one choices of an insertion, the smallest candidate was always selected.


Each case occupies 2 lines. The first line contains an positive integer N (<= 50,000). The second line gives the has table which consists of N integers where M of them are positive and these M integers are unique. Those cells occupied by non-positive integers are considered empty.


For each test case, output in a line the sequence of insertions. The numbers must be seperated by one space, and there must be no extra space at the end of the sequence.

A valid sequence of insertions is guarantee to exist for each of the input cases.

Sample Input

11 0 94 18 96 40 98 63 34 76 80
Sample Output

18 34 80 94 96 40 98 63 76 11

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享