Advertisement
mickypinata

SMMR-T046: Pleng

Jun 3rd, 2021
874
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long lli;
  5. typedef pair<int, int> pii;
  6.  
  7. #define x first
  8. #define y second
  9.  
  10. const int N = 1e5;
  11. const int MD = 2560;
  12.  
  13. pii dot[N + 10];
  14.  
  15. int main(){
  16.  
  17.     int nDot;
  18.     scanf("%d", &nDot);
  19.     for(int i = 1; i <= nDot; ++i){
  20.         scanf("%d", &dot[i].x);
  21.     }
  22.     for(int i = 1; i <= nDot; ++i){
  23.         scanf("%d", &dot[i].y);
  24.     }
  25.  
  26.     int currR = 0;
  27.     int currC = 0;
  28.     int overlap = 0;
  29.     int sum = 0;
  30.     for(int i = 2; i <= nDot; ++i){
  31.         int diffR = (dot[i].x - dot[i - 1].x) % MD;
  32.         int diffC = (dot[i].y - dot[i - 1].y) % MD;
  33.         int newR = ((lli)currR * diffC) % MD;
  34.         int newC = ((lli)currC * diffR) % MD;
  35.         int newSq = ((lli)diffR * diffC * (i - 1)) % MD;
  36.         overlap = (overlap + newR + newC + newSq) % MD;
  37.         sum = (sum + overlap) % MD;
  38.         currR = (currR + (lli)diffR * (i - 1)) % MD;
  39.         currC = (currC + (lli)diffC * (i - 1)) % MD;
  40.     }
  41.     cout << ((lli)nDot * (nDot - 1) / 2) % MD << '\n' << sum;
  42.  
  43.     return 0;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement