少了哪一份试卷
Two hundred students have IDs 1 to 200, and exactly one exam script is missing. (a) The pile is unsorted: how do you find the missing ID using little extra memory? (b) The pile is sorted by ID: how few scripts do you need to look at? (c) What if the pile is unsorted and two scripts are missing?
200 名学生的学号是 1 到 200,交上来的试卷少了恰好一份。(a) 试卷乱序,怎么用最少的额外空间找出少了谁?(b) 试卷已按学号排好序,最快要看几份?(c) 如果乱序且少了两份呢?
Frontier ACE 模拟练习4 步提示 + 答案
- 1乱序:用总和1 到 200 的和是 200 × 201 / 2 = 20 100。把手上 199 份的学号加起来,比如得 19 977,差 123,少的就是 123 号。只要一个累加变量,看每份一次。



