MPGHCC
Deadline of contest: April 27, 2010
Welcome to MPGH's Coding contest. The contest will contain 5 problems from which you must develop or alter an existing algorithm to solve the problem. For each problem you must code using either C/C++.
All input is FILE ONLY. The file will contain 5 test cases and you must output 5 lines for the test cases. Output will be directly to screen and must match requirements word for word and punctuation correct. Code will be submitted separately and only the .cpp/.c file.
The marking system is as follows:
- You will get 20 points for every test case you get correct
- You will get 5 points for every day you submit earlier
Maximum Score: 600
Email:
spaminator@live.ca
How to submit:
You will submit code with ONLY the .cpp/.c file. If you need to resubmit , add "[Resubmission]" to the end and you can only resubmit once.
To submit code, either PM me or e-mail me with the format as follows:
Subject: "Submission MPGHCC: [Your MPGH name] [Problem Number] [*Resubmission]"
Body:
Name: [Your name]
Age: [Your age]
Country: [Your country]
Example:
Subject:Submission MPGHCC: [zhaoyun333] [3]
Body:
Name: zhaoyun
Age: 15
Country: Canada
==================================================
Problem 1:
File Input: postcount.txt
MPGH needs a new post count system since most of it is spam. Count the number of posts each member has. Using the poster property of each post, count the posts made by each member.
Given N (1<N<100) number of total posts count the number of posts by each member. Print in order of first appearance.
Sample Input 1:
5
zhao
why06
retox
zhao
zhao
Sample Output 1:
zhao 3
why06 1
retox 1
Sample Input 2:
10
zhao
zhao
zhao
sealionne
why06
Dave
lala
zhao
zhao
why06
Sample Output 2:
zhao 5
sealionne 1
why06 2
Dave 1
lala 1
==================================================
Problem 2: Adding
File Input: "adding.txt"
Why06 needs help adding! He's forgot how to add really big numbers and multiple numbers at once!
Given a string of unknown numbers add them to find the sum. No number will be greater than 65536. Test cases will be separated by a newline.
Sample Input 1:
1+2+3+4+5
Sample Output 1:
15
Sample Input 2:
4+2+132+4
Sample Output 2:
142
==================================================
Problem 3: Birthday
File Input: "birthday.txt"
It's why06's birthday sometime soon and he want you to make a countdown for the day until his birthday! The problem is, you don't want to count the number of days, so you're going to compute it!
Given the current day, then month and why06s birthday in the same format, count the number of days until why06s birthday. Keep in mind leap years.
Sample Input 1:
1 1
1 2
Sample Output 1:
31
Sample Input 2:
12 30
1 1
Sample Output 2:
2
==================================================
Problem 4: CreditCard
File Input: "credit.txt"
Many hackers on MPGH have been using stolen credit cards to buy hacks. Why06 has instructed you to determine if the credit card is stolen or not. If it is stolen output who could have stole it. A credit card has a special private number that is prime, and the bank also has a special prime number.
Given a number N, if it only has two prime factors, than it is a legal credit card. But if the number has more than two prime factors, output all the prime factors of the number in ascending order to determine the user of the card.
Sample Input 1:
15
Sample Output 1:
Legit Card! Id 3 and 5.
Sample Input 2:
30
Sample Output 2:
Illegal Card! Ids 2,3,5.
==================================================
Problem 5: Ip Track
File Input: "iptrack.txt"
A hacker is using multiple servers to mask his IP Address, while doing a trace it was discovered that there are a bunch of false paths that lead to dead paths. To find where the server is, the deepest part of the network will lead to him. Two connections might point to the same server. Be careful of cycles that the hacker might have created!
Given N (1<N<100) number of servers and S number of connections , find the deepest path in the network and output the longest distance. 1 will be the MPGH server or the starting point.
Sample Input 1:
5
4
1 2
2 3
3 4
4 5
Sample Output 1:
4
Sample Input 2:
6
6
1 2
2 3
3 1
2 4
4 5
5 6
Sample Output 2:
4
Attached are the sample test data as requested. There are only 2 test cases in there each but when I mark there will be 5.