#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
int t;
cin>>t;
while(t--)
{
int x,y,k;
cin>>x>>y>>k;
int some;
int full;
if(x%k==0)
{
some=x/k;
}
else
{
some=(x/k)+1;
}
if(y%k==0)
{
full=y/k;
}
else
{
full=(y/k)+1;
}
// cout<<some<<" "<<full<<endl;
int mini=min(some,full);
int maxi=max(some,full);
int ans=mini+maxi+(maxi-mini);
if(some>full)
{
ans--;
}
cout<<ans<<endl;
}
return 0;
}
int main() {
int t;
cin >> t;
while (t--) {
ll x, y, k;
cin >> x >> y >> k;
ll moves = 0 ;
ll cx = 0 , cy = 0 ;
while (cx < x || cy < y) {
if (moves % 2 == 0) {
cx += std::min(k, x - cx);
} else {
cy += std::min(k, y - cy);
}
moves++;
}
cout<<moves<<"\n";
}
return 0;
}
C
Due to the poor performance of the main site for a long period, Codeforces Round 971 (Div. 4) will be unrated. We apologize for the inconvenience.
Читать полностью…if (jj_x == jj_y &&(x % k == 0 || y % k == 0)) { count11--; }
cout << count11 <<"\n";