Skip to content

L1-060 心理阴影面积

xlyy.JPG

这是一幅心理阴影面积图。我们都以为自己可以匀速前进(图中蓝色直线),而拖延症晚期的我们往往执行的是最后时刻的疯狂赶工(图中的红色折线)。由红、蓝线围出的面积,就是我们在做作业时的心理阴影面积。

现给出红色拐点的坐标 (x,y),要求你算出这个心理阴影面积。

输入格式:

输入在一行中给出 2 个不超过 100 的正整数 xy,并且保证有 x>y。这里假设横、纵坐标的最大值(即截止日和最终完成度)都是 100。

输出格式:

在一行中输出心理阴影面积。

友情提醒:三角形的面积 = 底边长 x 高 / 2;矩形面积 = 底边长 x 高。嫑想得太复杂,这是一道 5 分考减法的题……

输入样例:

tex
90 10
90 10

输出样例:

tex
4000
4000

Solution:

java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] input = in.readLine().split(" ");
        int x = Integer.parseInt(input[0]);
        int y = Integer.parseInt(input[1]);
        int sum = 5000;
        int a = x * y / 2;
        int b = (100 - x) * y;
        int c = (100 - x) * (100 - y) / 2;
        System.out.println(sum - a - b - c);
    }
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] input = in.readLine().split(" ");
        int x = Integer.parseInt(input[0]);
        int y = Integer.parseInt(input[1]);
        int sum = 5000;
        int a = x * y / 2;
        int b = (100 - x) * y;
        int c = (100 - x) * (100 - y) / 2;
        System.out.println(sum - a - b - c);
    }
}

Released under the MIT License.