-
Notifications
You must be signed in to change notification settings - Fork 0
/
763-b.cpp
56 lines (51 loc) · 931 Bytes
/
763-b.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <functional>
#include <array>
#include <climits>
//#include "debug.h"
using namespace std;
#define A first
#define B second
typedef long long ll;
constexpr int MOD = 1e9 + 7;
void solve(){
ll N, K;
cin >> N >> K;
ll i = 0;
while((1LL << i) <= K && (1LL << i) < N) {
i++;
}
ll moves = i;
ll done = 1LL << i;
//cout << done << '\n';
if(done >= N) {
cout << moves << '\n';
} else {
ll rem = (N - done) / K + ((N - done) % K == 0 ? 0 : 1);
cout << moves + rem << '\n';
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int T;
T = 1;
cin >> T;
while(T--) {
solve();
}
}