-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathB_A_Balanced_Problemset.cpp
92 lines (91 loc) · 1.39 KB
/
B_A_Balanced_Problemset.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define fr(i, a, b) for (ll i = a; i <= b; i++)
int tatto(int a, int b)
{
int ans = 0;
while (b)
{
if (b & 1)
ans = ans + a;
a = a + a;
b = b >> 1;
}
return ans;
}
int potty(vector<int> arr, int n, int x)
{
int lo = 0;
int hi = n - 1;
int mid = (hi + lo) / 2;
while (hi - lo > 1)
{
if (arr[mid] < x)
{
lo = mid + 1;
mid = (hi + lo) / 2;
}
else
{
hi = mid;
mid = (hi + lo) / 2;
}
}
if (arr[lo] == x)
{
return lo;
}
else if (arr[hi] == x)
{
return hi;
}
else
{
return -1;
}
}
void wushangclan()
{
ll x,n;
cin>>x>>n;
set<ll> s;
int m=0;
ll k=9;
ll p=sqrt(x);
fr(i,1,p){
if(x%i==0){
s.insert(i);
k--;
s.insert(x/i);
}else{
k++;
}
}
auto ind=s.lower_bound(x/n);
if(k==10){
m=60;
}
if(*ind>x/n){
ind--;
m++;
}
ll ans=*ind;
cout<<ans<<endl;
}
int main()
{
int t;
cin >> t;
while (t--)
{
wushangclan();
}
return 0;
}