#abc300g. G - P-smooth number

G - P-smooth number

Score : 600600 points

问题描述

一个正整数被称为 kk-光滑数,如果它的所有质因数都不超过 kk

给定一个整数 NN 和不超过 100100 的质数 PP,求不超过 NNPP-光滑数的数量。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

A positive integer is called a kk-smooth number if none of its prime factors exceeds kk.
Given an integer NN and a prime PP not exceeding 100100, find the number of PP-smooth numbers not exceeding NN.

Constraints

  • NN is an integer such that 1N10161 \le N \le 10^{16}.
  • PP is a prime such that 2P1002 \le P \le 100.

Input

The input is given from Standard Input in the following format:

NN PP

Output

Print the answer as an integer.

Sample Input 1

36 3

Sample Output 1

14

The 33-smooth numbers not exceeding 3636 are the following 1414 integers: 1,2,3,4,6,8,9,12,16,18,24,27,32,361,2,3,4,6,8,9,12,16,18,24,27,32,36.
Note that 11 is a kk-smooth number for all primes kk.

Sample Input 2

10000000000000000 97

Sample Output 2

2345134674

update @ 2024/3/10 08:24:56