*** Problem 1 *** --------------------- You are to write a program that accepts as input a single line with no more than 80 characters. The program is to find the last occurrence of the substring "acm", regardless of case, if it exists in the line. The program then outputs, on separate lines, (1) the part of the input that precedes the last occurrence of "acm", (2) the acm substring itself, and (3) the remainder of the input. If the last occurrence of "acm" is at the beginning of the input, the first output line is to be omitted. If the last occurrence of "acm" is at the end of the input, the third output line is to be omitted. If the substring "acm" does not occur in the input, the last two output lines should be omitted. You may assume that the input line will be 1 to 80 characters in length. Example 1: --------- Input: The ACM contest on March 18, 1994, was won by MacMillan High School. Output: The ACM contest on March 18, 1994, was won by M acM illan High School. Example 2: --------- Input: The University ski team placed second in the 1994 NCAA Championships. Output: The University ski team placed second in the 1994 NCAA Championships. *** Problem 2 *** --------------------- N people, numbered 1 to N, stand in a circle. They count off, and the Mth person drops out of the circle. Counting continues, starting with the next person, and again the Mth drops out. This continues until only one person is left. You are to write a program that inputs a value for N and for M, and then outputs the sequence in which the people drop out. The first number entered will be N, and the second will be M. You may assume that both N and M are greater than 0. Example 1: --------- Input: 7 4 Output: 4 1 6 5 7 3 Example 2: --------- Input: 4 7 Output: 3 4 1 *** Problem 3 *** --------------------- You are to write a program that accepts as input a single line with no more than 80 characters. The program is to output a line with the order of the words reversed. Words are defined as sequences of non-space characters. (Punctuation marks are considered to be non-space characters.) The order of the characters within the words is not to be changed. You may assume that one space will occur between words and that the input line will be 1 to 80 characters in length. Example 1: --------- Input: The University ski team placed second in the 1994 NCAA Championships. Output: Championships. NCAA 1994 the in second placed team ski University The Example 2: --------- Input: The ACM contest on March 18, 1994, was won by MacMillan High School. Output: School. High MacMillan by won was 1994, 18, March on contest ACM The *** Problem 4 *** --------------------- An abundant number is defined to be one which is less than the sum of its factors, excluding itself. For example, the factors of 12 are 1, 2, 3, 4, and 6. 1 + 2 + 3 + 4 + 6 = 16, which is greater than 12. Therefore, 12 is an abundant number. The first four abundant numbers are 12, 18, 20, and 24. You are to write a program that inputs an integer N and outputs the Nth abundant number. You may assume that N will be greater than 0 and less than 100. Example 1: --------- Input: 4 Output: 24 Example 2: --------- Input: 1 Output: 12 *** Problem 5 *** --------------------- Consider a group of N people, each of whom know one or more of the other people in the group. Let us define an "independent subgroup" of those N people such that everyone in the subgroup knows at least one other person in the subgroup, but nobody in the subgroup knows any of the N people who are not in the subgroup. Here is an example. Assume that N is 9 and that the people are numbered from 1 to 9: 1 and 2 know one another 1 and 3 know one another 2 and 4 know one another 3 and 5 know one another 6 and 7 know one another 6 and 8 know one another In this example 1, 2, 3, 4, and 5 constitute an independent subgroup, since each of them know at least one other person in the subgroup, but none of them knows anyone outside of the subgroup. 6, 7, and 8 constitute a second independent subgroup for the same reason. Finally, 9 constitutes a third independent subgroup since 9 does not know anyone else. You are to write a program that inputs information that describes a group of N people and outputs the number of independent subgroups within that group. The format of the input is as follows: N PersonA PersonB PersonA PersonB PersonA PersonB . . 0 0 Each pair of persons represents two people who know one another. Example 1: --------- Input: 9 1 2 1 3 2 4 3 5 (picture of graph) 6 7 6 8 0 0 Output: 3 Example 2: --------- Input: 5 1 2 1 5 2 3 (picture of graph) 3 4 0 0 Output: 1