经济文库 - 千万精品文档,你想要的都能搜到,下载即用。

通过典型案例来展示招聘笔试考试的应对技巧.pdf

无名指的加冕 、4 页 253.258 KB 访问 692.97下载文档
通过典型案例来展示招聘笔试考试的应对技巧.pdf通过典型案例来展示招聘笔试考试的应对技巧.pdf通过典型案例来展示招聘笔试考试的应对技巧.pdf通过典型案例来展示招聘笔试考试的应对技巧.pdf
当前文档共4页 2.97
下载后继续阅读

通过典型案例来展示招聘笔试考试的应对技巧.pdf

通过典型案例来展示招聘笔试考试的应对技巧 案例:中国银行 2018 的考试题:n 粒黄金,a[n]标识每粒黄金的重量。要打包出口 它们,每包重量不超过 40g,问如何搭配就能使得包数最小。 解:直观认为,先应该考虑重的,再考虑轻的。因此先根据重量对 n 粒黄金从重到 轻排序,排序后得到数组 b[n]。 策略:自然要从重到轻来考虑。先拿最重的,从它的下一个开始扫描,先找出第一 个能和它搭配一起出口的,即 b[0] + b[j] ≦ 40。 考虑到是招聘笔试,因此不能想得太复杂,否则时间来不及,因此只好朝规律方面 想。因此,就想到再找下一个还能搭配进来的。朝规律方面想,自然就想到要使用递归。 这样考虑的好处是:覆盖范围广。极端情况是:b[0] + b[n-1] > 40, 这样,b[0]只能 是一个出口,没有可搭配的。上面的方法把这种极端情况也覆盖进来了。 当然,上述方案也可能不是最佳的。没有关系,招聘笔试是机器打分。其办法是通 过用例来测试。上述方法能覆盖极端情况,因此,上述方案的得分能达到 90%。 因为是重的优先考虑。因此,肯定对每粒黄金都要标记其是否已经被搭配打包了。 于是对每粒黄金设置两个属性:b[i].weight 表示重量。 b[i].out=false 表示有待搭配处 理,b[i].out=true 表示已经搭配完了。 main ( ) { 先用冒泡法对 a[0..n-1]从重到轻排序: for ( i = n - 1; i --; i > 1) for ( j = 0; j ++; j < i) if (a[j] < a[j+1]) { k = a[j]; a[j] = a[j+1]; a[j+1] = k; } export_package_num = 0; //出口次数,要求的值; Package * current_package; i = 0; //从最重的开始考虑 while (i < n) { while ( b[i].out == true && i < n) i++; if ( i < n && b[i].out == false) { current_package = Figure_out_best_sub_package(40, i); export_package_num ++; print( “the %d th package weighs %d ”, export_package_num, current_package.Weight); i++; } } Print( “the minimum number of exports is %d”, export_package_num); } package Figure_out_best_sub_package(weight, start_index) Package * current_package; Package * package = new package( ); package.Add_Element(start_index); package.Set_Weight (b[start_index].weight); b[start_index].out ==true; if { (start_index < n - 1 ) { //表示不是最后一个元素 j = start_index + 1; while ( j < n ) { if ( b[j].out == false && b[start_index].weight + b[j].weight <= weight ) break; j++; } if (j -1) { b[p].out = false; p = current_package.Next_Element( ); } //设置当前最佳的搭配: current_package = next_package; } else { //next_package 竞争不过 current_package,被退回到等待打包 //的队列中: p = next_package.First_Element( ); while ( p > -1) { b[p].out = false; p = next_package.Next_Element( ); } } k = k + 1; while (k < n && b[k].out == true) k++; } //while ( k < n && b[k].out == false) { } // If (current_package.Weight( ) < weight - b[i].weight ) package.Add_Elements(current_package); package.Add_Weight(current_package); //if } } // if return package; } 例如,37, 37, 37, 37, 37, 37, 37, 37, 37, 35, 35, 35, 35, 35, 35, 35, 35, 例如,25, 25, 25, 25, 25, 25, 21, 21, 21, 21, 21, 例如,25, 25, 25, 25, 21, 21, 21, 35, 33, 33, 33, 33, 33, 33, 33, 33, 21, 19, 19, 19, 19, 19, 21, 19, 19, 19, 33, 24, 21 , 18, 21 , 18, 21 , 18, 21 , 18, 21 , 18, 21 , 18, 21 , 18, 21 , 18, 21 , 18, 15, 15, 15, 15, 15, 15, 15, 15, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 17, 14 , 8, 7, 6, 6, 3, 3, 18, 17, 14 , 8, 7, 6, 6, 18, 17, 14 , 8, 7, 6, 6, 18, 17, 14 , 8, 7, 6, 6, 18, 17, 14 , 8, 7, 6, 6, 18, 17, 14 , 8, 7, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 19, 6, 3, 27, 27, 27, 27, 27, 27, 27, 27, 19, 27, 24, 24, 24, 24, 24, 24, 24, 24, 18, 18, 17, 13 , 8, 15, 6, 18, 17, 13 , 8, 6, 6, 6, 18, 17, 13 , 8, 6, 6, 6, 18, 17, 13 , 8, 6, 6, 6, 12, 6, 11, 9, 8, 7, 6, 6, 4, 2, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 1 1 1 1 1 1 1 3, 3, 3, 3, 2, 2, 2 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 2 2 2 2 3, 3, 3, 3, 3, 3, 3, 4,3, 3, 3, 3, 3, 3, 3, 3, 4,3, 3, 3, 3, 3, 3, 3, 3, 4,3, 3, 3, 3, 3, 3, 3, 3, 3 3 3 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 3 2, 1

相关文章