forked from earmer/Luogu_answers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
29 lines (25 loc) · 754 Bytes
/
main.cpp
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
// Copyright (c) 2022. limingrui0.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int post(int l, int r) {
if (l < 0 && r > 0)
return (abs(l - 1) >> 1) + (abs(l + 1) >> 2) + (abs(r + 1) >> 1) + (abs(r / 4) + 1);
if(abs(l) > abs(r))
swap(l, r);
return ((abs(r) + 1) >> 1) + (abs(r) >> 2) - (abs(l) >> 1) - ((abs(l) - 1) >> 2);
}
int main() {
int n;
int l, r;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> l >> r;
cout << post(l, r);
}
return 0;
}