Answered step by step
Verified Expert Solution
Question
1 Approved Answer
COP 3 5 0 3 Homework # 1 : SGA PresidentFilename: destroy.javaTime Limit: 2 seconds ( per input case ) Standard Input, Standard OutputLiam and
COP Homework #: SGA PresidentFilename: destroy.javaTime Limit: seconds per input caseStandard Input, Standard OutputLiam and Sathwika are enjoying being TAs for COP but they have decided to aim for higher goals, like running for SGA President and Vice President. Unfortunately, they have realized that with tickets from the previous election such as JoshJad and BradBreon they have no hope of winning because all winning tickets must have two distinct names that start with the same first letter, so Liam and Sathwika just won't doNaturally, Liam was despondent about this revelation and to make himself feel better came up with a problem for all of the Computer Science students. Given the names of each student at UCF, Liam wondered how many potential winning pairs for SGA President and VicePresident there might be In order for a pair to have the potential to win, their names must be different but start with the same first letter. Since President and Vice President are different roles, we count the ticket of Josh and Jad differently than the ticket of Jad and Josh. The first name listed is the candidate for President while the second name listed is the corresponding candidate for Vice President. Note that UCF has many students that share a first name, so there might be several potential winning pairs of Josh and Jad. For example, if there are Joshes and Jads on campus, there are JoshJad pairs with a Josh running for President and a Jad running for Vice President.The Problem:Given the names of each UCF student, calculate the number of possible PresidentVicePresident pairs who have a potential to win the SGA election.The Input:The first line of input contains a single positive integer, n n representing the number of UCF students. The following n lines each contain a single first name of one UCF student. Allnames will consist of uppercase letters only and be between and letters long, inclusive. Eachline represents a distinct student, but distinct students may have the same first name.The Output:On a line by itself, output the total number of PresidentVice President pairs that have a chance to
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started