9530 T - Mao - Programming - 2018
9530 T - Mao - Programming - 2018
This one-hour computer programming competition will consist of a collection of problems, each of which
will require students to write a program that displays correct output for each input value or set of input
values provided by the judge. Each problem's point value is displayed in the problem. Problems may be
solved in any order.
Each school is limited to one team of three members and must supply its own computer and necessary
power cables. Acceptable programming languages are BASIC, Pascal, C/C++, Python, and Java. No use
of calculators or cell phones is permitted during the contest. One programming language reference book
is allowed.
Each program may be run only once and must run continuously for all input lines. Points are assigned by
the correctness of each output line. Partial credit is possible. If, in the opinion of a judge, the data has
been entered incorrectly, a restart is possible. No additional programming or corrections will be permitted
before additional runs of a restarted program.
If you wish to have a problem graded, one member of your team should raise his/her hand and wait for a
judge to come to your area. The judge will provide input and will check to make sure your program
displays the correct output for the value(s) provided.
Whenever you ask to have a problem judged, the judge must initial your score sheet in the appropriate
location to indicate whether or not the problem was solved correctly and enter any scores that have been
earned.
Numerical input and output values will be sized such as to fit within ordinary (String, int, double …) data
types.
Unless the problem states differently, round-off error in output values will be ignored, provided the output
is no further than .01 away from the correct answer.
All programming must STOP when the judges call time. Teams will have one additional opportunity to
have a SINGLE program scored after time is called. If a team is having a problem graded when time is
called, they are still allowed to have an additional problem graded.
All DISPUTES will be handled in the testing room by the judges. All decisions of the judges are final.
Places will be determined as follows: Highest Score, Sudden Death (first points missed).
The sample input and output accompanying each problem do not necessarily test all possibilities.
Open Computer Test FAMAT Sate Convention 2018
Scoring Sheet
Member 1: ____________________________________________________________
Member 2: ____________________________________________________________
Subsection
Problem (max
Total
points)
1 2 3 4 5 6 7 8
1. (5)
2. (15) NA
3. (20)
5. (15) NA
6. (22)
7. (25) NA
Final Score
Judges: Enter subsection points and initial in each subsection. When problem is finished, total its line.
Students: Fill out your school’s name and id, your members’ names, and your captain’s id. Don’t fill out
the points table – the judges will do that when they grade your answers.
Open Computer Test FAMAT Sate Convention 2018
Alright, time for some programming! Each problem will have a problem statement, and a sample
input/output. Judges will have you enter each of the input cases and write on the score sheet the number
of points you receive when you call them over to grade a program. Programs that fail to compile or run
will not receive points for input cases that were not entered due to program crashes. You are only allowed
one submission per program. Don’t forget to hand in your scoring sheet at the end of the contest!
Sample Input:
55
10 10
13 37
42 99
13 12
Sample Output:
1). 10 25
2). 20 100
3). 50 481
4). 141 4158
5). 25 156
Open Computer Test FAMAT Sate Convention 2018
Input will consist of five lines, each containing the name of a college. For each line of input,
output the name of the college, a colon, the number of D’s in its name, another colon, and then
the phrase “An excellent institution of higher education” if there are no D’s in its name, and the
phrase “A sad place for delinquents and other ne’er-do-wells” otherwise.
Naturally, D’s in any form are bad, so both upper and lowercase D’s should be treated equally.
Princeton
Harvard
Davidson’s Clown College
Sample Output:
Princeton : 0 : An excellent institution of higher education
Harvard : 1 : A sad place for delinquents and other ne’er-do-wells
Davidson’s Clown College : 2 : A sad place for delinquents and other ne’er-do-wells
Open Computer Test FAMAT Sate Convention 2018
Your interviewer states the question: “I own N coins. Coin i∈ {1 , 2 … N } has a probability of
pi
of landing on heads when it is flipped. After I independently flip each coin, what is the
100
mean and standard deviation of the number of heads I see?”
Input will consist of five lines. Each line will be of the form “ N p 1 p2 … pN ”, where each pair of
adjacent pi’s is separated by a space. N will be a nonnegative integer less than 20 and each pi
will be of the form ab, where a and b are each in the range {0 ,1 , … 9 } and represent digits in the
number pi. For each line of input, output a line of the form u , σ where u is the average number
of heads, and σ is the standard deviation of the number of heads. There’s no need to round your
answers.
For example, in the second line of sample input, the question involves two coins, one of which is
fair and the other has a 1 in 4 chance of coming up heads.
Credit will be given if your value for u is within 0.01 of the true value and your value for σ is
within 0.1 of the true value. (Hint: This is a fairly wide tolerance range for σ . Why don’t you
flip a few coins yourself?) (Second hint: Question 6 provides a formula that might be helpful.)
Sample Input:
1 50
2 50 50
3 50 50 50
4 50 60 70 80
5 90 90 99 99 04
Sample Output:
0.5,0.5
1.0,0.71
1.5,0.7
2.6,0.92
3.82,0.49
Open Computer Test FAMAT Sate Convention 2018
Input will consist of 8 lines of the form “ X i :Y i”, where X i is a single capital letter and Y i is an
integer between 0 and 10.
Sample Output:
10 | X
09 | X
08 | X
07 | X
06 | X
05 | X
04 | XX
03 | XX
02 | XX
01 |XXX
----
ABC
Scoring:
Open Computer Test FAMAT Sate Convention 2018
3 points each for correct locations of digits, |’s, -‘s, X i ’s, X’s, and spaces. All members of a
category must be placed correctly to receive the points for that category.
Luckily, the coolness of a person is determined uniquely by their name. A person is cool if an
odd number of the following 6 conditions hold or if either or conditions 1 and 2 hold:
1.) They are named Sam.
2.) They are named Rob Snow.
3.) Their name starts with an S.
4.) The sum of the numerical values of the letters in their name (a=1, b=2, ..., z=26)
is of the same parity as the number of conditions, excluding conditions 4 and 5,
that they satisfy.
5.) Condition 4 is unsatisfied.
6.) The number of vowels (aeiou only) in their name is equal to the number of
consonants (including y) in their name.
Naturally, a name consists only of vowels, consonants, commas, and spaces, only the first letter
of which is considered for condition 3. Input will consist of five lines, each containing a name.
For each line of input, output a line of the form “Satisfied Y conditions and is very cool.” if the
person was cool, and a line of the form “Satisfied Y conditions and is totally lame” otherwise,
where Y is the number of conditions that person satisfied. All conditions are case insensitive, for
example, “Sam” and “sam” both satisfy condition 1.
Sample input:
Sam
Rob
Janet Yellen
Sonny Perdue
Some other team
Sample Output:
6. Making Money (22 points, 3 for each of 7 cases and 1 for the final line)
Despite your extremely accurate coolness detection program, you’ve decided that friends are
overrated and now seek the company of money alone. You’ve decided on a simple momentum
strategy: buy stocks that did well in the past. To implement this, you’ve decided to build a
program that tells you what stocks to buy.
Input will consist of 7 lines, each of the form “X:Y:Z”, where X is a ticker and Y, Z are positive
integer or decimal numbers. A ticker is a series of capitalized alphabetic characters. Y is the
stock’s price at the start of the year, and Z is the stock’s price now.
Output will consist of 8 lines, the first 7 of which should be of the form “A: B”, where A is a
ticker from the input, and B is the percentage gain, rounded to one decimal place, that the stock
has achieved over the past year. The 8th line should contain the phrase “QUICKLY! BET ALL
YOUR MONEY ON X”, where X is the ticker that has the highest percentage gain since the start
of the year. Lines should be sorted by percentage gain (highest at the top). No two input lines
will contain the same ticker or contain tickers with the same percentage gain, because we’re not
evil.
Sample Input:
SAM:1:1000
OTHERTEAM:1000:1
YOU:1:999.998
DECIMALNUMBERS:13.37:42.0
ROBSNOW:1:999.999
AAPL:156.34:160.78
AMZN:956.67:1001.0
Sample Output:
SAM: 99900.0
ROBSNOW: 99899.9
YOU: 99899.8
DECIMALNUMBERS: 214.1
AMZN: 4.6
AAPL: 2.8
OTHERTEAM: -99.8
QUICKLY! BET ALL YOUR MONEY ON SAM
Open Computer Test FAMAT Sate Convention 2018
Input will consist of 5 lines. Each line will begin with an integer2 ≤ n≤ 4 , which will be
immediately followed by a colon and a semi-colon delimited list of n coordinate pairs of the form
(x , y ), where x and y are non-negative integers no greater than 10000. No lines will contain
spaces.
Output will consist of 5 lines, each of which will contain the correlation between the x ’s and y ’s
of the corresponding input line. There’s no need to round.
Recall the following formulas related to sample standard deviation ( s x) and correlation (r xy), or
just read them below:
√
n
∑ ( x i− x́ )2
i=1
sx=
n−1
( ) ( )( )
1
n
x i−x́ y i− ý
r xy = ∗∑ ∗
n−1 i=1 s x sy
Sample Output:
1
-1