Repository navigation
Expand file tree
/
Copy path1352C.cpp
More file actions
172 lines (161 loc) · 6.44 KB
/
Copy path1352C.cpp
File metadata and controls
172 lines (161 loc) · 6.44 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
using namespace std;
namespace io {
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << p.first << " " << p.second; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (size_t i = 0; i < vec.size(); ++i) os << vec[i] << (i + 1 < vec.size() ? " " : ""); return os; }
template<typename K, typename V> ostream& operator<<(ostream& os, const map<K, V>& m) { for (auto it = m.begin(); it != m.end(); ++it) os << it->first << " " << it->second << (next(it) != m.end() ? "\n" : ""); return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& matrix) { for (const auto& row : matrix) os << row << "\n"; return os; }
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1, T2>& p) { return is >> p.first >> p.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& vec) { for (auto& v : vec) is >> v; return is; }
template<typename K, typename V> istream& operator>>(istream& is, map<K, V>& m) { size_t n; is >> n; while (n--) { K key; V value; is >> key >> value; m[key] = value; } return is; }
template<typename T> istream& operator>>(istream& is, vector<vector<T>>& matrix) { for (auto& row : matrix) for (auto& val : row) is >> val; return is; }
};
// Type definitions
typedef long long ll;
typedef long long lli;
typedef long double lld;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<lli> vll;
typedef vector<vll> vvl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
// Constants
const lli mod = 1e9 + 7;
const lli MAXN = 1e6;
const double eps = 1e-10;
const lli LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};
const string ny[] = {"NO", "YES"};
const string nys[] = {"No", "Yes"};
// Macros
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rev(x) reverse(all(x))
#define srt(x) sort(all(x))
#define maxx (lli) fmax
#define minn (lli) fmin
#define pb push_back
#define F first
#define S second
#define pi acos(-1.0)
#define sq(x) ((x) * (x))
#define issq(x) (((lli)(sqrt((x)))) * ((lli)(sqrt((x)))) == (x))
#define lg(r, n) (int)(log2(n) / log2(r))
#define setpre(n) fixed << setprecision(n)
#define UNIQUE(a) (a).erase(unique(all(a)), (a).end())
#define debug(x) \
cerr << #x << " = [ "; \
for (const auto &val : x) \
cerr << val << " "; \
cerr << "]\n"; //works fine for now
#define take(p, n, T) \
vector<T> p(n); \
for (auto &i : p) \
cin >> i;
#define input(x) \
for (auto &i : x) \
cin >> i
#define print(x) \
for (auto &i : x) \
cout << i << " "; \
cout << "\n"
#define arrsum(arr) std::accumulate(arr.begin(), arr.end(), 0LL)
#define error(args...) \
{ \
string _s = #args; \
replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); \
istream_iterator<string> _it(_ss); \
err(_it, args); \
}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}
// Loop macros
#define loop(i, n) for (int i = 0; i < (n); ++i)
#define rloop(i, n) for (int i = (n) - 1; i >= 0; --i)
#define sloop(i, s, t) for (int i = s; i < t; ++i)
// Utility macros
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) <= (r))
#define pcnt __builtin_popcountll
#define snuke srand((unsigned)clock() + (unsigned)time(NULL))
#define show_var(x) cout << #x << " = " << x << endl
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define bn(x) ((1 << (x)) - 1)
#define dup(x, y) (((x) + (y) - 1) / (y))
#define drnd(x, y) (((x) + (y) / 2) / (y))
#define newline puts("")
#define YES puts("YES")
#define NO puts("NO")
#define tc \
int t; \
cin >> t; \
for (int ii = 1; ii <= t; ++ii)
#define tc0 \
int t = 1; \
for (int ii = 1; ii <= t; ++ii)
#define nl cout << "\n";
#define gp " "
#define case(ii) cout << "Case " << ii << ": "
#define freopen \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
// Graph input macro
#define readgraph(arr, edges) \
for (int i = 0; i < (edges); i++) \
{ \
int a, b; \
cin >> a >> b; \
arr[a].pb(b); \
arr[b].pb(a); \
}
#define by(x) [](const auto &a, const auto &b) { return a.x < b.x; }
#define tolower_str(s) transform(all(s), s.begin(), ::tolower)
#define toupper_str(s) transform(all(s), s.begin(), ::toupper)
#define cng_str(s) transform(all(s), s.begin(), [](char c) { return c ^ ' '; })
#define clr(arr, val) memset(arr, val, sizeof(arr))
// Utility functions
inline lli gcd(lli a, lli b) { return b == 0 ? a : gcd(b, a % b); }
#define lcm(a, b) ((a) * (b)) / gcd(a, b)
inline lli madd(lli a, lli b, lli m = mod) { return (a + b) % m; }
inline lli msub(lli a, lli b, lli m = mod) { return (a - b + m) % m; }
inline lli mmul(lli a, lli b, lli m = mod) { return (a * b) % m; }
inline lli mpow(lli base, lli exp, lli m = mod) {
lli res = 1;
while (exp > 0) {
if (exp & 1) res = mmul(res, base, m);
base = mmul(base, base, m);
exp >>= 1;
}
return res;
}
inline lli minv(lli a, lli m = mod) { return mpow(a, m - 2, m); }
// *****************************************************
// ------------------- CODE STARTS HERE ----------------
// *****************************************************
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
tc {
lli n,k;
cin>>n>>k;
cout<< *ranges::partition_point(views::iota(0ll,(lli)1e18),[&](lli x){return x-x/n<k;});
}
}