首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 考研频道 > 历年真题 > 专业课真题 >

上海交通大学2005年计算机复试机试题详解

2009-07-02 
学习网  

第一部分:考试说明

           ◎考试说明◎

题目与时间
本次上机考试分两部分,第一部分为试机,半小时,只有一道题,供大家熟悉上机环境
,不计成绩。第二部分为正式考试,三个小时,共三道题。

评分方法:
我们采取黑盒测试法评分。对您的每个程序,我们将使用若干个测试数据进行测试,您
的程序在时间限制内每通过一个测试数据就能得到相应的分数。第一题有8个数据,第二
题有6个数据,第三题有6个数据,共20个数据,每个数据5分,总分100分。

程序提交说明:
  请在d盘中建立一个您的考生号(?)为目录名的文件夹,并务必将您的程序存放在这
个文件夹中,文件名必须取为:大写题号.cpp(.c/.Java),如a.cpp,b.c或c.java等,
任何其他文件名的程序不予评分。请勿对同一道题提交不同语言版本的程序,否则对该
题我们将不予评分。


其它:
l 请在您的程序中一律采用标准输入输出(屏幕),具体可参照我们给出的sample程

2 对每个测试数据,您的程序的运行时间限制为1秒
3 如果您需要使用eclipse,请运行e:\exam\eclipse\run.bat


对您的建议:
l 仔细阅读题目,一定要确保您的输入输出符合要求
2 仔细阅读和理解sample input and output能帮助您正确理解题意,甚至想出解题方

3 不必书写注释,更不必美化程序,我们只进行黑盒测试
4 您可以参考题目中所给提示进行编程,但也完全可以不参考,只要您的程序能够完
成给定要求
5 如果您没有把握完成一个能正确处理所有输入数据情况的程序,您可以考虑在程序
中仅处理一些数据规模不是太大的情况,这样仍可能使您得到大多的分数
6 不要编写破坏性程序,否则产生的结果对您也是破坏性的


第二部分:原题
problem a: goldbach's conjecture

the famous goldbach's conjecture states that a sufficiently large positive
even number can always be decomposed as the sum of a pair of prime numbers.
this conjecture has never been proved or disproved, which left as a great
challenge to human beings. take it easy, we don't require you to solve the
conjecture here. instead, you are only required to write a verifier tool
for the conjecture, which decomposes a positive integer(not necessarily
large even ones) into a pair of prime numbers if possible.

input specification:
the positive integer n which is no greater than 100,000.

output specification:
in a single line the two prime numbers p1 and p2 separated by a single
space, or a single 0 if no such pair exist. p1 must be no greater than p2
and if multiple pairs of p1 and p2 exist as solutions, output the pair of
p1, p2 such that p1 is the smallest.

hint:
l take care of the cases where n is very small and the cases where n is
odd
2 be sure that you output the correct pair if multiple pairs exist

sample input 1:
19
sample output 1:
2 17

sample input 2:
24
sample output 2:
5 19

 

problem b: mines

many mines have been detected to exist in a small area of the sahara desert,
which is a severe threat to the habitants nearby. those mines are quite
special and called the "super chaining" ones BECause if any one of them is
triggered and exploded, every mine within 5 meters from it would also be
triggered. those triggered mines explode and continue to trigger other
mines in the same manner, a kind of chain reaction. so terrible it is!
with the help of a newly developed mine detector, lieutenant john has
recently been able to detect the exact positions of all the mines. and now,
he is making a plan on how to eliminate all the mines by triggering all of
them, an economic way as it is in the desert. as a young sergeant, your

热点排行