CF2009C The Legend of Freya the Frog 题解
原题传送门
分析
考虑
时间复杂度:
Code
/*
Codeforces CF2009C The Legend of Freya the Frog
*/
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a;i <= b;i++)
#define per(i,a,b) for(int i = a;i >= b;i--)
#define pb push_back
#define PII pair<int,int>
using namespace std;
typedef long long ll;
int t;
ll x,y,k;
inline void solve()
{
cin>>x>>y>>k;
ll pos = (x + k - 1) / k;//向上取整
ll res = (y + k - 1) / k;
if(pos <= res)
{
cout<<res * 2<<"\n";
}
else
{
cout<<pos * 2 - 1<<"\n";
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>t;
while(t--)
{
solve();
}
return 0;
}
AC submissions