CF83D.Numbers

提高+/省选-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

一个再普通不过的日子,瓦莱拉去上学了(毕竟工作日他无处可去)。数学课上,他最喜爱的埃文斯老师向同学们讲解了约数的概念。尽管瓦莱拉热爱数学,但他对这一特定主题却毫无兴趣。更甚的是,这内容看起来如此枯燥,以至于他在课堂中途就睡着了。唯有学校铃声那响亮的鸣响,才打断了他香甜的梦。

当然,宝贵的授课内容和老师的讲解全都错过了。然而,瓦莱拉无论如何都得完成家庭作业。由于他对这部分新知识完全一无所知,因此无法独立完成任务。正因如此,他来向你求助——毕竟你是他最好的朋友,你实在无法拒绝帮忙。

瓦莱拉的家庭作业只有一道题,虽然题目表述极为简单,但其解法却并不平凡。题干如下:若考虑区间 ([a, b]) 内的所有正整数,则需统计该区间中满足“其最小约数(不考虑等于 1 的约数)恰好为某个给定整数 (k)”的数的个数。换言之,你需要统计区间 ([a, b]) 中所有满足“不能被 (2) 到 (k-1) 之间的任意整数整除,但能被 (k) 整除”的数的个数。

输入格式

The first and only line contains three positive integers a, b, k (1 ≤ a ≤ b ≤ 2·109, 2 ≤ k ≤ 2·109).

第一行且唯一一行包含三个正整数 aa、bb、kk(1 ≤ a ≤ b ≤ 2⋅1091 ≤ a ≤ b ≤ 2·10^9,2 ≤ k ≤ 2⋅1092 ≤ 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.

对题目样例的说明:

第一个样例的答案是数字 2、4、6、8、10。

第二个样例的答案是 15、21。

第三个样例中不存在满足条件的数字。

输入解题思路,AI测评打分。不知道怎么写?

首页