Advertisement
Guest User

e

a guest
Mar 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cstring>
  3. #include <algorithm>
  4. #include <cmath>
  5. #include <cctype>
  6. #include <iostream>
  7. #include <vector>
  8.  
  9. using namespace std;
  10.  
  11. #define maxn (200000)
  12. #define ll long long
  13. #define ull unsigned long long
  14. #define PB(x) push_back(x)
  15. #define MP(x,y) make_pair(x,y)
  16.  
  17. ll x[maxn],y[maxn];
  18. int n;
  19. ll sumx,sumy,sumx2,sumy2,N;
  20.  
  21. int main(){
  22.     scanf("%d",&n); N=n;
  23.     for (int i=1;i<=n;i++) {
  24.         int a,b; scanf("%d%d",&a,&b);
  25.         x[i]=a; y[i]=b;
  26.     }
  27.  
  28.     for (int i=1;i<=n;i++) sumx+=x[i];
  29.     for (int i=1;i<=n;i++) sumy+=y[i];
  30.     for (int i=1;i<=n;i++) sumx2+=x[i]*x[i];
  31.     for (int i=1;i<=n;i++) sumy2+=y[i]*y[i];
  32.  
  33.     cout << ((-2ll*sumx*sumx+2ll*N*sumx2) + (-2ll*sumy*sumy+2ll*N*sumy2))/2ll << endl;
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement