且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Codeforces Round #308 (Div. 2) A. Vanya and Table

更新时间:2022-08-13 08:44:56

题目链接:http://codeforces.com/contest/552/problem/A
hint: 就是求几个矩形的面积

#include <iostream>
#include <cmath>
using namespace std;
struct point
{
    int x;
    int y;
}a[2];
int main()
{
    int m;
    while(cin>>m)
    {
        int sum=0;
        while(m--)
        {
        //注释的是方法一
            cin>>a[0].x>>a[0].y>>a[1].x>>a[1].y;
//            for(int i=a[0].x; i<=a[1].x; i++)
//                for(int j=a[0].y; j<=a[1].y; j++)
//                  sum++;
            sum+=abs(a[1].x-a[0].x+1)*abs(a[1].y-a[0].y+1);
        }
        cout<<sum<<endl;
    }
    return 0;
}