-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy path1080B.cpp
More file actions
42 lines (36 loc) · 735 Bytes
/
1080B.cpp
File metadata and controls
42 lines (36 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
long long l, r;
while(t--){
cin>>l>>r;
long long odd_l, odd_r;
l--;
if(l % 2 == 0){
odd_l = l/2 * l/2;
}
else{
odd_l = (l/2 + 1) * (l/2 + 1);
}
long long even_l = l/2 * (l/2 + 1);
if(r % 2 == 0){
odd_r = r/2 * r/2;
}
else{
odd_r = (r/2 + 1) * (r/2 + 1);
}
long long even_r = r/2 * (r/2 + 1);
long long even_s = even_r - even_l;
long long odd_s = odd_r - odd_l;
cout<<(even_s - odd_s)<<"\n";
}
return 0;
}