320SC Python/Java

Java Python Computer Science 320SC – (2024)
Programming Assignment 1
Due: Friday, July 26 (11:59pm)
Requirements
This first assignment lets you get familar with submission of simple (but correct and efficient) algorithms
to the CompSci 320 automated marker. There are two algorithms/programs required but three different
submissions for marks (two data sets for one of them). It is worth 5% of your total course marks. (Note
future programming assignments will require much more work to obtain the same number of marks so
you are encouraged to make a serious attempt on this one.)
Problem Statement 1: Computing GCD
Read in a sequence of 32-bit signed integers (several per line separated by spaces) until a single line
containing zero (0). There will be at most 1000 integers per line. For each line except for the last one,
compute the greatest common divisor (gcd) of that set of integers. Then output on a line the statement
“The gcd of the integers is x.” where x is the desired gcd. Note, for this problem, all answers should
be non-negative.
The input should be taken from keyboard/stdin/System.in.
Sample Input:
2 4 8
15 0 -5
6 20 25 5 30
28 21952 49 294 3822
0
The precisely formated output should be sent to console/stdout/System.out.
Sample Output:
The gcd of the integers is 2.
The gcd of the integers is 5.
The gcd of the integers is 1.
The gcd of the integers is 7.
Practice I/O
For all programs, the input should be taken from stdin and output stdout. A practice problem (no
marks) for this input will be availabl 320SC、Python/Java e on the automarker. Instead of outputting the gcd, simply output
the number of integers for each test case on a line by itself (nothing else). The number of output lines
should be the same as the number of test cases being processed.
1Problem Statement 2: Minimum Double Pair
The input format for this problem is the same as in Problem 1 but all integers (per line) are assumed to
be different. We read in a sequence of 32-bit signed integers (several per line separated by spaces) until
a single line containing zero (0). For each line except for the last one, compute the smallest sum s such
that there are two different pairs of integers (x1, x2) and (y1, y2), where x1 < x2, x1 6= y1 < y2 6= x2,
that both sum to s (e.g., x1 + x2 = y1 + y2 = s). If such a sum s is possible, output on a line “yes: s”.
Otherwise output on a line “None”.
Sample Input:
2 1 3 4
10 20 40 45 5 15 25
24 23 8 29 31 5
10 20 50 51 52 53 54 12 15 16
0
Sample Output:
yes: 5
yes: 25
None
yes: 62
Submission
You need to use just one source file per problem. The file extension indictes which programming
language you are using.
You submit to our automated marking system http://www.cs.auckland.ac.nz/automated-marker. Limited
feedback will be given by the submission system (see Help/FAQ) and you are allowed to resubmit
up to 8 times per problem before a 20% penalty applies.
There is two marks awarded for Problem 1 and three marks awarded for Problem 2 (with the harder
input cases being worth one mark)         

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值