Wednesday, October 16, 2013

light OJ.com "1000 - Greetings from LightOJ" solution in c++

OMG, it is so amazing to be able to solve OJ problems by yourself. i wish good luck to you also guys.

here is the question link: http://lightoj.com/volume_showproblem.php?problem=1000

here is problem: 1000 - Greetings from LightOJ
Time Limit: 0.5 second(s)Memory Limit: 32 MB
You are one of the most talented programmers and like to solve challenging problems. And my task is to make your life a bit complex by setting some easy looking hard brain storming problems such that you can sharpen your skills by practicing here. So, I wrote a code which shows a message like the following line:
Greetings from LightOJ
After that the code will select a random problem for you from my problems database based on your previously solved problems, your skills and your weaknesses. But while I was coding for implementing this great idea, I found that, all of my problems are scattered in 2 computers. So, I have to merge them before running my code.
Now you are given the number of problems in each of the computers, you have to find the total number of problems. You can safely assume that no problem is stored in multiple computers. So, all the problems are distinct.

Input

Input starts with an integer T (≤ 125), denoting the number of test cases.
Each case starts with a line containing two integers a and ba denotes the number of problems in the first computer and b denotes the number of problems in the second computer. You can safely assume that a and b will be non-negative and not greater than 10.

Output

For each case, print the case number and the total number of problems. See the samples for exact formatting.

Sample Input

Output for Sample Input

2
1 7
9 8
Case 1: 8
Case 2: 17



and here is my c++ solution link: http://ideone.com/Iw7489

and here is my c++ solution to "Greetings from lightOJ" problem:
#include <iostream>
using namespace std;

int main() {
// your code goes here
int T, a, b;
//T <= 125;
//0 <= a <= 10;
//0 <= b <= 10;
cin >> T;
for (int i = 1; i <= T; i++) {
cin >> a >> b;
cout << "Case " << i << ": " << a+b << "\n";
}

return 0;
}

No comments:

Post a Comment