题意:T组输入,每组输入一个n,x,n为需要到的门牌号,x为第二层以上每层有多少户,无论什么情况,第一层只有2户,求n号在第几层
题解:读懂即可ac
code:
#include<bits/stdc++.h>#pragma GCC optimize(2)
#define rep(i,a,n) for (int i=a;i<=n;i++)//i为循环变量,a为初始值,n为界限值,递增
#define per(i,a,n) for (int i=a;i>=n;i--)//i为循环变量, a为初始值,n为界限值,递减。using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll<<60;
const int mod=1e9+7;ll read()//快读
{
ll w = 1, s = 0;char ch = getchar();while (ch < '0' || ch>'9') {
if (ch == '-') w = -1; ch = getchar(); }while (ch >= '0' && ch <= '9') {
s = s * 10 + ch - '0'; ch = getchar(); }return s * w;
}
void solve(){
ll n,x;cin>>n>>x;if(n>2){
if(n>x){
cout<<((n-2)+(x-1))/x+1<<endl;}else cout<<2<<endl;}else cout<<1<<endl;
}int main(){
int _;cin>>_;while(_--) solve();return 0;
}