fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin >> t;
  7. while(t--){
  8. int x,y,d;
  9. cin >> x >> y >> d;
  10. int mX = (x+d-1)/d;
  11. int mY = (y+d-1)/d;
  12. if(x < y)
  13. cout << 2*mY << endl;//2*mY
  14. if(x >= y){
  15. cout << mX + max(mY,(mX-1)) << endl;;
  16. }
  17. }
  18. }
  19.  
Success #stdin #stdout 0.01s 5288KB
stdin
3
9 11 3
0 10 8
1000000 100000 10
stdout
8
4
199999