A. 2-3-numbers

Codeforces
IDCF953A
Time1000ms
Memory256MB
Difficulty
English · Original
Chinese · Translation
Formal · Original
A positive integer is called a _2-3-integer_, if it is equal to 2_x_·3_y_ for some non-negative integers _x_ and _y_. In other words, these integers are such integers that only have 2 and 3 among their prime divisors. For example, integers 1, 6, 9, 16 and 108 — are 2-3 integers, while 5, 10, 21 and 120 are not. Print the number of _2-3-integers_ on the given segment \[_l_, _r_\], i. e. the number of sich _2-3-integers_ _t_ that _l_ ≤ _t_ ≤ _r_. ## Input The only line contains two integers _l_ and _r_ (1 ≤ _l_ ≤ _r_ ≤ 2·109). ## Output Print a single integer the number of _2-3-integers_ on the segment \[_l_, _r_\]. [samples] ## Note In the first example the _2-3-integers_ are 1, 2, 3, 4, 6, 8 and 9. In the second example the _2-3-integers_ are 108, 128, 144, 162 and 192.
一个正整数被称为 _2-3整数_,如果它等于 $2^x \cdot 3^y$,其中 $x$ 和 $y$ 是某些非负整数。换句话说,这些整数的素因子中仅包含 $2$ 和 $3$。例如,整数 $1$、$6$、$9$、$16$ 和 $108$ 是 2-3 整数,而 $5$、$10$、$21$ 和 $120$ 不是。 请输出给定区间 $[l, r]$ 上 _2-3整数_ 的数量,即满足 $l \leq t \leq r$ 的 _2-3整数_ $t$ 的个数。 输入仅一行,包含两个整数 $l$ 和 $r$($1 \leq l \leq r \leq 2 \cdot 10^9$)。 请输出一个整数,表示区间 $[l, r]$ 上 _2-3整数_ 的数量。 在第一个例子中,_2-3整数_ 是 $1$、$2$、$3$、$4$、$6$、$8$ 和 $9$。 在第二个例子中,_2-3整数_ 是 $108$、$128$、$144$、$162$ 和 $192$。 ## Input 输入仅一行,包含两个整数 $l$ 和 $r$($1 \leq l \leq r \leq 2 \cdot 10^9$)。 ## Output 请输出一个整数,表示区间 $[l, r]$ 上 _2-3整数_ 的数量。 [samples] ## Note 在第一个例子中,_2-3整数_ 是 $1$、$2$、$3$、$4$、$6$、$8$ 和 $9$。在第二个例子中,_2-3整数_ 是 $108$、$128$、$144$、$162$ 和 $192$。
**Definitions** Let $ S = \{ 2^x \cdot 3^y \mid x, y \in \mathbb{Z}_{\geq 0} \} $ be the set of 2-3-integers. **Constraints** Given integers $ l, r \in \mathbb{Z} $ such that $ 1 \leq l \leq r \leq 2 \cdot 10^9 $. **Objective** Compute $ \left| S \cap [l, r] \right| $.
Samples
Input #1
1 10
Output #1
7
Input #2
100 200
Output #2
5
Input #3
1 2000000000
Output #3
326
API Response (JSON)
{
  "problem": {
    "name": "A. 2-3-numbers",
    "description": {
      "content": "A positive integer is called a _2-3-integer_, if it is equal to 2_x_·3_y_ for some non-negative integers _x_ and _y_. In other words, these integers are such integers that only have 2 and 3 among thei",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF953A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "A positive integer is called a _2-3-integer_, if it is equal to 2_x_·3_y_ for some non-negative integers _x_ and _y_. In other words, these integers are such integers that only have 2 and 3 among thei...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "一个正整数被称为 _2-3整数_,如果它等于 $2^x \\cdot 3^y$,其中 $x$ 和 $y$ 是某些非负整数。换句话说,这些整数的素因子中仅包含 $2$ 和 $3$。例如,整数 $1$、$6$、$9$、$16$ 和 $108$ 是 2-3 整数,而 $5$、$10$、$21$ 和 $120$ 不是。\n\n请输出给定区间 $[l, r]$ 上 _2-3整数_ 的数量,即满足 $l \\leq ...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ S = \\{ 2^x \\cdot 3^y \\mid x, y \\in \\mathbb{Z}_{\\geq 0} \\} $ be the set of 2-3-integers.\n\n**Constraints**  \nGiven integers $ l, r \\in \\mathbb{Z} $ such that $ 1 \\leq l \\leq r \\l...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments