Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- #pragma GCC optimize("03")
- #pragma GCC target("avx2")
- #define long long long
- #define nln '\n'
- using namespace std;
- long sqr(long x)
- {
- return x*x;
- }
- long distance(pair<long, long> a, pair<long, long> b)
- {
- return sqr(b.first-a.first) + sqr(b.second-a.second);
- }
- int main()
- {
- cin.tie(0)->sync_with_stdio(0);
- cout.tie(0)->sync_with_stdio(0);
- // Input
- //freopen("distanceofpairs.inp", "r", stdin);
- long n;
- cin >> n;
- vector<pair<long, long>> a(n);
- for (auto &i : a)
- cin >> i.first >> i.second;
- // Process
- long ans = 0;
- for (long i = 0; i < n-1; ++i)
- for (long j = i+1; j < n; ++j)
- ans += distance(a[i], a[j]);
- // Output
- cout << ans << nln;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment