Update XSM OJ

This commit is contained in:
Fengyi Chen 2024-05-26 22:12:23 +08:00
parent 2fe17ab3fd
commit 8f564ca60e
2 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,27 @@
#include <iostream>
#define int long long
using namespace std;
signed main()
{
int N;
cin >> N;
int count = 0;
for (int i = 1; i <= N / 3; ++i)
{
for (int j = i + 1; j <= N / 2; ++j)
{
int k = N - i - j;
if (k > j && k != 3 && k != 7 && i != 3 && i != 7 && j != 3 && j != 7 && k != 0)
{
++count;
}
}
}
cout << count << endl;
return 0;
}

View File

@ -0,0 +1,35 @@
#include <iostream>
#include <vector>
using namespace std;
struct Rectangle {
int x1, y1, x2, y2;
};
int main() {
int n;
cin >> n;
vector<Rectangle> rectangles(n);
for (int i = 0; i < n; ++i) {
cin >> rectangles[i].x1 >> rectangles[i].y1 >> rectangles[i].x2 >> rectangles[i].y2;
}
int totalArea = 0;
for (int i = 0; i < n; ++i) {
totalArea += (rectangles[i].x2 - rectangles[i].x1) * (rectangles[i].y2 - rectangles[i].y1);
for (int j = i + 1; j < n; ++j) {
int x_overlap = max(0, min(rectangles[i].x2, rectangles[j].x2) - max(rectangles[i].x1, rectangles[j].x1));
int y_overlap = max(0, min(rectangles[i].y2, rectangles[j].y2) - max(rectangles[i].y1, rectangles[j].y1));
totalArea -= x_overlap * y_overlap;
}
}
cout << totalArea << endl;
return 0;
}