Tuenti Challenge 8

Challenge 1 - Waffle love

Your store, 20 Waffles, is famous for having the most beautiful and delicious waffles in the entire city. You and your staff have put a lot of effort into making sure the shape of your most requested product, the rectangular waffle, is always perfect and that your customers are always happy with them. Sometimes, they even count the number of holes in your waffles. Sometimes they even ask you for help.

Given each waffle’s number of vertical and horizontal lines, how many holes does it have?

Input

The first line has an integer C, which is the number of cases for the problem. Then C lines follow and each one has two integers N and M, which are the number of vertical and horizontal lines on the waffle.

Output

For each case, there should be a line starting with "Case #x: " followed by the number of holes in the waffle.

Limits

  • 1 ≤ C ≤ 100
  • 2 ≤ N, M ≤ 10000

Sample Input

3
2 2
3 2
4 3

Sample Output

Case #1: 1
Case #2: 2
Case #3: 6

Here are some diagrams for the cases above to help you understand the problem better.

1
2x2
12
3x2
123
456
4x3

Test your code

You can test your program against both the input provided in the test phase and the input provided in the submit phase. A nice output will tell you if your program got the right solution or not. You can try as many times as you want to. Be careful with extra whitespaces, the output should be exactly as described.

Test your program against the input provided in the test phase

Download test input

Program output:

Test your program against the input provided in the submit phase

Download input

Program output:

During the submit phase, in some problems, we might give your program harder inputs. As with the test token, a nice output will tell you if your program got the right solution or not. You can try as many times as you need.

In the actual contest you first need to solve the test phase before submitting the code, you must provide the source code used to solve the challenge and you can only submit once (once your solution is submitted you won't be able to amend it to fix issues or make it faster).

If you have any doubts, please check the info section.

Problem stats

Completion time: min: 0:02:22 h
10th percentile: 0:11:08 h
90th percentile: 13:24:14 h
max: 142:26:09 h
Test phase time: 10th percentile: 0:09:09 h
90th percentile: 11:05:42 h
Submit phase time: 10th percentile: 0:00:55 h
90th percentile: 0:21:19 h
# of completions:650