Advertisement
Guest User

Untitled

a guest
Jan 7th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <cstdio>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int pL,pT,pR,pB,qL,qT,qR,qB;
  8. scanf("%d%d%d%d%d%d%d%d",&pL,&pT,&pR,&pB,&qL,&qT,&qR,&qB);
  9. int p = (pR - pL) * (pB - pT)
  10. int q = (qR - qL) * (qB - qT)
  11. int distanceR = min(pR, qR);
  12. int distanceL = max(pL, qL);
  13. int distanceRL = max(0, distanceR- distanceL);
  14. int distanceB = min(pB, qB);
  15. int distanceT = max(pT, qT);
  16. int distanceBT = max(0, distanceB - distanceT);
  17. int result = p + q - distanceRL * distanceBT;
  18. printf("%d\n", result);
  19. return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement