fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin >> t;
  7.  
  8. while (t--) {
  9. long long l, r, k;
  10. cin >> l >> r >> k;
  11.  
  12. if (l == r) {
  13. if (k >= 1) {
  14. cout << 1 << endl;
  15. } else {
  16. cout << 0 << endl;
  17. }
  18. } else {
  19. long long count = (r - l + 1) / k;
  20. cout << count << endl;
  21. }
  22. }
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5280KB
stdin
8
3 9 2
4 9 1
7 9 2
2 10 2
154 220 2
147 294 2
998 24435 3
1 1000000000 2
stdout
3
6
1
4
33
74
7812
500000000