HDU 6577 Class

Class

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)

Problem Description

Avin has two integers a, b (1 ≤ a, b ≤ 1, 000).
Given x = a + b and y = a - b, can you calculate a*b?

Input

The first line contains two integers x, y.

Output

Print the result of a*b.

Sample Input

4 2

Sample Output

3

思路:

解个方程组就行了。

#include 
#include 
using namespace std;
int main() {
    int x, y;
    scanf("%d %d", &x, &y);
    int a = (x + y) / 2;
    int b = x - a;
    printf("%d\n", a * b);
    return 0;
}

你可能感兴趣的:(HDU)