Problem - D - Codeforces
题意:

思路:
和蓝桥杯国赛有道题类似,都是用中点来确定图形防止精度缺失
应该算是典
 
 
Code:
#include <bits/stdc++.h>
using i64 = long long;
constexpr int N = 2e3 + 10;
constexpr int M = 1e6 + 10;
constexpr int P = 2600;
constexpr i64 Inf = 1e18;
constexpr int mod = 1e9 + 7;
constexpr double eps = 1e-6;
int n;
int x[N], y[N];
void solve() {
    std::cin >> n;
    for (int i = 1; i <= n; i ++) std::cin >> x[i] >> y[i];
    std::map<std::pair<int,int> ,int> mp;
    for (int i = 1; i <= n; i ++) {
        for (int j = i + 1; j <= n; j ++) {
            int a = x[i] + x[j];
            int b = y[i] + y[j];
            mp[{a, b}] ++;
        }
    }
    int ans = 0;
    for (auto t : mp) {
        int cnt = t.second;
        int k = cnt * (cnt - 1) / 2;
        ans += k;
    }
    std::cout << ans << "\n";
}
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int t = 1;
    while (t--) {
        solve();
    }
    
    return 0;
}







![[LeetCode周赛复盘] 第 112场双周赛20230903](https://img-blog.csdnimg.cn/f7d3a794b35542ab89e33303b90394e9.png)











