Programming Team:  Practice Contest, 3-Feb-05
Mt Lebanon HS 2004-5
David Kosbie

Part 1 of 2This is a Full Contest.  Work as teamsGood luck!

For this contest, use the problem set from the official SRU 2003 Programming Contest.

Part 2 of 2:  This is a Quick Contest.  Work as individuals, not in teams.  Good luck!

Q1:  Read in six doubles – m1, b1, m2, b2, m3, b3 – which describe the slopes and y-intercepts of 3 lines. Print out the area of the triangle described by the three lines (with vertices at the 3 points of intersection of the lines), or “no triangle” if one does not exist.

Q2:  Read in a word (composed of upper and lowercase letters) and output YES if the word has more vowels than consonants and NO otherwise. The vowels are a, e, i, o, and u.

Q3:  A simple cipher translates the nth letter of the alphabet to the (n+k)th letter, with wraparound. So, if k=1, A becomes B, B becomes C, and so on, and Z becomes A. Read in a word (composed of uppercase letters) and an integer k, and print out the word using this cipher and the given value of k.

Q4:  Read in four positive integers, r, g, b, and n. Assuming you have r red blocks, g green blocks, and b blue blocks in a bag, and you randomly select n blocks from the bag (without replacing them), print out the probability (to within 0.01) that you did not select any blocks of one color (so you picked all red-and-green, or all blue-and-green or all red-and-blue).

Q5:  Read in an integer n, where 3 < n < 1 million, and print out the largest prime number less than n. Your program must run in less than one second.