A8089 | Numbers
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
One quite ordinary day Valera went to school (there's nowhere else he should go on a week day). In a maths lesson his favorite teacher Ms. Evans told students about divisors. Despite the fact that Valera loved math, he didn't find this particular topic interesting. Even more, it seemed so boring that he fell asleep in the middle of a lesson. And only a loud ringing of a school bell could interrupt his sweet dream.
Of course, the valuable material and the teacher's explanations were lost. However, Valera will one way or another have to do the homework. As he does not know the new material absolutely, he cannot do the job himself. That's why he asked you to help. You're his best friend after all, you just cannot refuse to help.
Valera's home task has only one problem, which, though formulated in a very simple way, has not a trivial solution. Its statement looks as follows: if we consider all positive integers in the interval $[a;b]$ then it is required to count the amount of such numbers in this interval that their smallest divisor will be a certain integer $k$ (you do not have to consider divisor equal to one). In other words, you should count the amount of such numbers from the interval $[a;b]$ , that are not divisible by any number between $2$ and $k-1$ and yet are divisible by $k$ .
Of course, the valuable material and the teacher's explanations were lost. However, Valera will one way or another have to do the homework. As he does not know the new material absolutely, he cannot do the job himself. That's why he asked you to help. You're his best friend after all, you just cannot refuse to help.
Valera's home task has only one problem, which, though formulated in a very simple way, has not a trivial solution. Its statement looks as follows: if we consider all positive integers in the interval $[a;b]$ then it is required to count the amount of such numbers in this interval that their smallest divisor will be a certain integer $k$ (you do not have to consider divisor equal to one). In other words, you should count the amount of such numbers from the interval $[a;b]$ , that are not divisible by any number between $2$ and $k-1$ and yet are divisible by $k$ .
输入格式
The first and only line contains three positive integers $a$ , $b$ , $k$ ( $1<=a<=b<=2·10^{9},2<=k<=2·10^{9}$ ).
输出格式
Print on a single line the answer to the given problem.
输入输出样例
输入 #1
1 10 2
输出 #1
5
输入 #2
12 23 3
输出 #2
2
输入 #3
6 19 5
输出 #3
0
Comments to the samples from the statement:
In the first sample the answer is numbers $2,4,6,8,10$ .
In the second one — $15,21$
In the third one there are no such numbers.
In the first sample the answer is numbers $2,4,6,8,10$ .
In the second one — $15,21$
In the third one there are no such numbers.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted