Pagini recente » Borderou de evaluare (job #2450672) | Borderou de evaluare (job #2785612) | Borderou de evaluare (job #2427467) | Borderou de evaluare (job #1129777) | Cod sursa (job #3233523)
#include <iostream>
#include <fstream>
#include <set>
#include <utility>
using namespace std;
struct Point {
int x, y;
bool operator<(const Point& other) const {
if (x != other.x) return x < other.x;
return y < other.y;
}
};
int main() {
ifstream inFile("dreptunghiuri.in");
ofstream outFile("dreptunghiuri.out");
int m, n;
inFile >> m >> n;
set<Point> points;
for (int i = 0; i <= m; ++i) {
for (int j = 0; j <= n; ++j) {
points.insert({i, j});
}
}
int count = 0;
for (auto p1 = points.begin(); p1 != points.end(); ++p1) {
for (auto p2 = next(p1); p2 != points.end(); ++p2) {
for (auto p3 = next(p2); p3 != points.end(); ++p3) {
for (auto p4 = next(p3); p4 != points.end(); ++p4) {
if (p1->x + p4->x == p2->x + p3->x && p1->y + p4->y == p2->y + p3->y) {
++count;
}
}
}
}
}
outFile << count << endl;
inFile.close();
outFile.close();
return 0;
}