` `#include <cstdio>
#include <cstring>
typedef unsigned long long U64;
const int MAX_ SQRT_ N = 1E5;
struct euler_ Sieve {
static const int MAX_ N = MAX_ SQRT_ N;
bool f[MAX_ N + 10];
int p[MAX_ N + 10];
int p_ N;
inline void operator () (int n) {
memset (F, 0, sizeof f);
p_ N = 0;
for (int i = 2; I < = n; ++i) {
if (f[i]) {
p[++p_ N] = I;
}
for (int j = 1; p[j] * I < = n; ++j) {
f[p[j] * * = = {
f[p[j]; ((%) = = 0); 25_ Sieve {
u64 n;
u64 b[2 * MAX_ SQRT_ N + 10]; / / all possible n / I values are from big to small (crap)
int b_ N, sqrt_ N;
inline int locate (U64 I) {return I < sqrt_ N? B_ N - I + 1: n / I;} / / find b[j] = = I position j
int d0[2 * MAX_ SQRT_ N + 10]; / / store the value of H function, array named personal hobby. The value of the H function is only O (\sqrt n). The location at I is not h (I), but h (b[i])
inline void pre_. Calc () {/ / calculate h function
for (int i = 1; I < = b_) N; ++i) d0[i] = 1 * (b[i] - 1); / / h (b[i], 0), j = 0, it is understood that there is no I minimum quality factor > p_. J "this restriction can be. Here and the following 1 * are represented by i^k (k = 0 (not the input k))
for (int j = 1; (U64) es.p[j] * es.p[j] = = n; ++j) {/ / enumerated prime number (= 1); ++i) {/ / enumerated useful, that is, b[i]
d0[i] = d0[i] - 1 * (d0[locate (b[i] / es.p[j])] d0[locate (es.p[j] - 1)]; / / there must be p[j] - 1 < \sqrt n, so it is bound to find a legal location (not falling within a segment) / / because the value of b[i] is small from the main road, so the order of evaluation is no problem, no additional cache array
}
}
}
u64 f_ is needed. A0_ K;
inline U64 f_ A0 (int E) {return e * f_ A0_ K + 1;}
inline U64 f (int p, int E) {return f_ A0 (E);}
u64 Calc (U64 n, int m) {/ / compute g function
u64 RST =
u64 A0 (1) * (d0[locate (n)] - d0[locate (es.p[m])];
for (int j = m + 1; (U64) es.p[j] * * f = =; ()) = (=); (()) = (1); (()) * (*) = <; = +; = + (=); (+) = ((+)); * ((/ /), +) (+); + ((+) + 1 +);
}
inline U64 operator () (U64 n_) U64 f_ A0_ K_ {
n = n_ ;
f_ A0_ K = f_ A0_ K_
sqrt_ / sub block N = 0; while ((U64) sqrt_). N * sqrt_ N < n) ++sqrt_ N;
b_ N = 0; for (U64 I = 1; I < = n; I = n / (n / I) + 1) b[++b_ N] = n / I; I / processing auxiliary summation function
pre_ Calc (); g / / sum
es.p[0] = 0, d0[b_ N + 1] = 0;
return Calc (n, 0) + 1; / / + 1 is the dump of 1
}
} MNS;
int main () {/ / freopen (" In.in "," R "," stdin ";
int TC; scanf ("%d ", &tc); / / int TC = 1;
es (MAX_) SQRT_ N + 5); / / sieve prime number
while (tc--) {
u64 n, f_ A0_ K; scanf ("%llu%llu", &n, &f_) A0_ K);
printf ("%llu\n", MNS (n, f_). A0_ K);
}
return 0;}