//include //------------------------------------------ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";} #define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}} using LL = long long; //------------------------------------------ //------------------------------------------ constexpr LL mod = 1e9 + 7; constexpr LL MAX_N = 200200; LL POW_MOD(LL N, LL P, LL M) { LL ret = 1; while (P > 0) { if (P & 1LL) ret = (ret * N) % M; N = (N * N) % M; P >>= 1LL; } return ret; } LL fac[MAX_N]; LL inv[MAX_N]; void setup() { fac[0] = fac[1] = 1; inv[0] = inv[1] = 1; for (LL i = 2; i < MAX_N; i++) { fac[i] = fac[i - 1] * i; fac[i] %= mod; inv[i] = POW_MOD(fac[i], mod - 2, mod); } } LL nCr_mod(LL n, LL r) { if (r < 0 || r > n) return 0; return fac[n] * inv[r] % mod * inv[n - r] % mod; } template vector DIVISOR(T n) { vector v; for (T i = 1; i * i <= n; ++i) { if (n % i == 0) { v.push_back(i); if (i != n / i) { v.push_back(n / i); } } } sort(v.begin(), v.end()); return v; } template vector> DIVISOR_ALL(T n) { vector> res(n + 1); for (T i = 1; i <= n; i++) { for (T j = i; j <= n; j += i) { res[j].push_back(i); } } return res; } int main() { setup(); LL N, K; cin >> N >> K; auto divisors = DIVISOR(N); vector dp(N + 1, 0); // x回回して回転対称 for (auto x: divisors) { LL P = N / x; if (K % P == 0) { dp[x] = nCr_mod(N / P, K / P); } } SHOW_VECTOR(dp); for (auto x: divisors) { for (LL y = x * 2; y <= N; y += x) { if (N % y == 0) { dp[y] -= dp[x]; dp[y] += mod; dp[y] %= mod; } } } LL ans = 0; for (LL i = 0; i < N; i++) { ans += dp[i]; ans %= mod; } cout << ans << endl; return 0; }