zoukankan      html  css  js  c++  java
  • A. Vanya and Table

    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output
     

    Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows are numbered by integers from 1 to 100 from bottom to top, the columns are numbered from 1 to 100 from left to right.

    In this table, Vanya chose n rectangles with sides that go along borders of squares (some rectangles probably occur multiple times). After that for each cell of the table he counted the number of rectangles it belongs to and wrote this number into it. Now he wants to find the sum of values in all cells of the table and as the table is too large, he asks you to help him find the result.

    Input

    The first line contains integer n (1 ≤ n ≤ 100) — the number of rectangles.

    Each of the following n lines contains four integers x1, y1, x2, y2 (1 ≤ x1 ≤ x2 ≤ 100, 1 ≤ y1 ≤ y2 ≤ 100), where x1 and y1 are the number of the column and row of the lower left cell and x2 and y2 are the number of the column and row of the upper right cell of a rectangle.

    Output

    In a single line print the sum of all values in the cells of the table.

    Examples
    input
    2
    1 1 2 3
    2 2 3 3
    output
    10
    input
    2
    1 1 3 3
    1 1 3 3
    output
    18

    Note

    Note to the first sample test:

    Values of the table in the first three rows and columns will be as follows:

    121

    121

    110

    So, the sum of values will be equal to 10.

    Note to the second sample test:

    Values of the table in the first three rows and columns will be as follows:

    222

    222

    222

    So, the sum of values will be equal to 18.

    题意:

    给定n组的两点坐标,求以两点做对角顶点的矩形占多少格子即面积和。

    附AC代码:

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 
     4 int main() {
     5     int n;
     6     cin >> n;
     7     int sum = 0;
     8     while (n--) {
     9         int x1, x2, y1,y2;
    10         cin >> x1 >> y1>>x2>>y2;
    11         int x = x2-x1+1;
    12         int y = y2-y1+1;
    13         sum += x*y;
    14     }
    15     cout << sum << endl;
    16     return 0;
    17 }
  • 相关阅读:
    『ORACLE』 DBLINK(11g)
    『ORACLE』 对永久表空间进行DDL操作(11g)
    『ORACLE』 对永久表空间进行DML操作(11g)
    『ORACLE』 数据库suspend模式(11g)
    『ORACLE』 数据库quiesce模式(11g)
    『ORACLE』 数据库restricted模式(11g)
    [转]为什么不去读顶级会议上的论文
    learn from 德国老师
    IDA 调试 Android
    L#中 int.TryParse 有问题
  • 原文地址:https://www.cnblogs.com/Kiven5197/p/5850984.html
Copyright © 2011-2022 走看看