fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int T;
  6. cin >> T;
  7. while (T--) {
  8. long long L, R;
  9. cin >> L >> R;
  10. // 计算区间[L, R]中奇数的个数
  11. long long count = (R - L + 2) / 2;
  12. if ((L % 2 == 0) && (R % 2 == 0)) {
  13. count = (R - L) / 2;
  14. }
  15. cout << count << endl;
  16. }
  17. return 0;
  18. }
Success #stdin #stdout 0s 5320KB
stdin
1
8 78
stdout
35