fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int t;
  7. cin >> t;
  8. while(t--){
  9. long x,y,k;
  10. cin >> x >> y >> k;
  11. long moves_X = (x+k-1)/k;
  12. long moves_Y = (y+k-1)/k;
  13. if(moves_X <= moves_Y)
  14. cout << moves_Y*2;
  15. else
  16. (moves_X-1)*k >= y ? cout << moves_X*2 - 1 : cout << moves_X*2;
  17. cout << endl;
  18. }
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0.01s 5280KB
stdin
3
9 11 3
0 10 8
1000000 100000 10
stdout
8
4
199999