fork download
  1.  
  2.  
  3. #ifdef Asaad
  4. #include "cp.h"
  5. #define debug(...) _dbg_many(#__VA_ARGS__, __VA_ARGS__)
  6. #define here cerr << "LINE " << __LINE__ << "\n"
  7. #else
  8. #include <bits/stdc++.h>
  9. using namespace std;
  10. /*
  11.   #include <ext/pb_ds/assoc_container.hpp>
  12.   #include <ext/pb_ds/tree_policy.hpp>
  13.   using namespace __gnu_pbds;
  14.   template<class T>
  15.   using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  16.   */
  17. #define debug(...)
  18. #define here
  19. #endif
  20.  
  21.  
  22.  
  23. #define ll long long
  24. #define int long long
  25. #define all(x) x.begin(), x.end()
  26. #define siz(x) ((int)x.size())
  27. #define yes cout << "YES\n"
  28. #define no cout << "NO\n"
  29. #define f first
  30. #define s second
  31. #define eb emplace_back
  32. #define pb push_back
  33.  
  34.  
  35. const int mod = 1e9+7;
  36. const int N = 200009;
  37. const long long inf = 1e18+12309138;
  38. double eps = 1e-9;
  39.  
  40.  
  41.  
  42.  
  43.  
  44. void tc () {
  45. //nb=
  46.  
  47. int w;
  48. int x, y;
  49. int ans[2] = {0};
  50. cin >> x >> y >> w;
  51. if ( w == 1 ) {
  52. cout << x << " " << y << "\n";
  53. return;
  54. }
  55. bool p = 0;
  56. bool big = ( x < y );
  57. int dif = abs(x-y);
  58. ans[big] += (dif+w-1)/w;
  59. int tot = min(x, y)*2;
  60. int rem = (w-(dif%w))%w;
  61. if ( rem > 0 ) {
  62. if ( big && (tot>0) ) ans[0]++;
  63. else if ( rem > 1 && (tot>1) ) ans[1]++;
  64. p^=rem%2;
  65. if ( tot <= rem ) {
  66. cout << ans[0] << " " << ans[1] << "\n";
  67. return;
  68. }
  69. tot-= rem;
  70. }
  71. ans[0] += tot/w;
  72. ans[1] += tot/w;
  73. p^=((tot/w)*w)%2;
  74. tot-= (tot/w)*w;
  75. if ( tot > 0 ) ans[p]++;
  76. if ( tot > 1 ) ans[p^1]++;
  77.  
  78. cout << ans[0] << " " << ans[1] << "\n";
  79.  
  80.  
  81.  
  82.  
  83. }
  84.  
  85.  
  86.  
  87.  
  88.  
  89. signed main () {
  90. ios::sync_with_stdio(false);
  91. cin.tie(0);
  92. //freopen( "input.txt", "r", stdin );
  93. //freopen( "output.txt", "w", stdout );
  94. //cout << fixed << setprecision(9);
  95. //pre();
  96. int t=1;
  97. cin >> t;
  98.  
  99. for (int i=1; i<=t; i++) {
  100. #ifdef Asaad
  101. auto start = chrono::high_resolution_clock::now();
  102. //cout << "---Case " << i << " Start---\n\n";
  103. #endif
  104.  
  105. tc();
  106.  
  107.  
  108. #ifdef Asaad
  109. auto end = chrono::high_resolution_clock::now();
  110. //cout << "---Case " << i << " End---\n";
  111. cerr << "Time #" << i << ": " << chrono::duration_cast<chrono::milliseconds>(end - start).count() << "ms" << endl;
  112. //cout << "--------------\n";
  113. #endif
  114. }
  115. }
  116.  
  117.  
  118.  
  119.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
2 2