AlbertMourato

Untitled

Dec 7th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. typedef long long ll;
  5. int main() {
  6.     int n;
  7.     cin>>n;
  8.     ll k, a, b, c, d, dist = 0, pares = 0, distPosi = 0;
  9.     while(n>0){
  10.         pares = 0;
  11.         distPosi = 0;
  12.         dist = 0;
  13.         cin>>a>>b>>c>>d;
  14.         for(int i = a;i<=b;i++){
  15.             dist = k-(i+c);
  16.             if(dist==0){
  17.                 pares+=d-c;
  18.             }else if(dist<0){
  19.                 pares+=d-c+1;
  20.             }else{
  21.                 pares+=d-dist-c;
  22.             }
  23.         }
  24.         cout<<pares<<"\n";
  25.       n--;
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment