【NEEPU OJ】1005--This is a easy problem 4 U.
Description
We have two rows. There are a dots on the top row and b dots on the bottom row. We draw line segments connecting every dot on the top row with every dot on the bottom row. The dots are arranged in such a way that the number of internal intersections among the line segments is maximized. To achieve this goal we must not allow more than two line segments to intersect in a point. The intersection points on the top row and the bottom are not included in our count; we can allow more than two line segments to intersect on those two rows. Given the value of a and b, your task is to compute P(a,b), the number of intersections in between the two rows. For example, in the following figure a = 2 and b = 3. This figure illustrates that P(2,3) = 3.
Input
Each line in the input will contain two positive integers a (0 < a ≤ 20000) and b (0 < b ≤ 20000). Input is terminated by a line where both a and b are zero. This case should not be processed. You will need to process at most 1200 sets of inputs.
Output
For each line of input, print in a line the serial of output followed by the value of P(a,b). Look at the output for sample input for details. You can assume that the output for the test cases will fit in 64-bit signed integers.
输入样例 1
2 2
2 3
3 3
0 0
输出样例 1
Case 1: 1
Case 2: 3
Case 3: 9
提示
来源
UVA Online Judge
代码
#include <cstdio> using namespace std; int main(){ long long a, b, res; int cnt = 0; while(~scanf("%lld %lld", &a, &b)){ if(a == 0 && b == 0) break; cnt++; res = a * (a - 1) * b * (b - 1) / 4; printf("Case %d: %lld\n", cnt, res); } return 0; }
- A problem is easy(南阳oj216)(数学变型)
- SDNU__1221.This is a water problem.
- NYOJ-216-A problem is easy
- 杭电oj An easy problem
- 【BZOJ4999】This Problem Is Too Simple!(线段树)
- Maven Problem: No compiler is provided in this environment
- 【bzoj4999】This Problem Is Too Simple!
- A problem is easy
- 题目216 A problem is easy
- A Problem is Preventing Windows from Accurately Checking the License for this Computer
- 【NEEPU OJ】3004--马走日
- NYOJ 26 A problem is easy
- 【BZOJ4999】This Problem Is Too Simple!(线段树)
- NOJ 题目216:A problem is easy
- nyoj_216_A problem is easy_201312051117
- 216 A problem is easy
- hdu-oj 2123 An easy problem
- ZZUOJ-10436: easy problem
- bzoj4999 This Problem Is Too Simple!(树链剖分+动态开点线段树)
- There is a problem with this website’s security certificate in IE