B. Position in Fraction

Codeforces
IDCF900B
Time1000ms
Memory256MB
Difficulty
mathnumber theory
English · Original
Chinese · Translation
Formal · Original
You have a fraction . You need to find the first occurrence of digit _c_ into decimal notation of the fraction after decimal point. ## Input The first contains three single positive integers _a_, _b_, _c_ (1 ≤ _a_ < _b_ ≤ 105, 0 ≤ _c_ ≤ 9). ## Output Print position of the first occurrence of digit _c_ into the fraction. Positions are numbered from 1 after decimal point. It there is no such position, print _\-1_. [samples] ## Note The fraction in the first example has the following decimal notation: . The first zero stands on second position. The fraction in the second example has the following decimal notation: . There is no digit 7 in decimal notation of the fraction.
你有一个分数 $\frac{a}{b}$。你需要在该分数的小数表示中,找到数字 $c$ 首次出现的位置(小数点后)。 第一行包含三个单个正整数 $a$, $b$, $c$($1 ≤ a < b ≤ 10^5$, $0 ≤ c ≤ 9$)。 请输出数字 $c$ 在小数表示中首次出现的位置。位置从紧接小数点后的第 $1$ 位开始编号。如果不存在这样的位置,请输出 _-1_。 第一个示例中的分数的小数表示如下:。第一个零位于第二位。 第二个示例中的分数的小数表示如下:。其小数表示中不存在数字 $7$。 ## Input 第一行包含三个单个正整数 $a$, $b$, $c$($1 ≤ a < b ≤ 10^5$, $0 ≤ c ≤ 9$)。 ## Output 请输出数字 $c$ 在小数表示中首次出现的位置。位置从紧接小数点后的第 $1$ 位开始编号。如果不存在这样的位置,请输出 _-1_。 [samples] ## Note 第一个示例中的分数的小数表示如下:。第一个零位于第二位。第二个示例中的分数的小数表示如下:。其小数表示中不存在数字 $7$。
**Definitions** Let $ a, b, c \in \mathbb{Z} $ with $ 1 \leq a < b \leq 10^5 $ and $ 0 \leq c \leq 9 $. Let $ x = \frac{a}{b} $, and let $ d_1, d_2, d_3, \dots $ be the decimal digits of $ x $ after the decimal point. **Objective** Find the smallest positive integer $ k $ such that $ d_k = c $. If no such $ k $ exists, return $ -1 $.
Samples
Input #1
1 2 0
Output #1
2
Input #2
2 3 7
Output #2
\-1
API Response (JSON)
{
  "problem": {
    "name": "B. Position in Fraction",
    "description": {
      "content": "You have a fraction . You need to find the first occurrence of digit _c_ into decimal notation of the fraction after decimal point.",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF900B"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You have a fraction . You need to find the first occurrence of digit _c_ into decimal notation of the fraction after decimal point.\n\n## Input\n\nThe first contains three single positive integers _a_, _b...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "你有一个分数 $\\frac{a}{b}$。你需要在该分数的小数表示中,找到数字 $c$ 首次出现的位置(小数点后)。\n\n第一行包含三个单个正整数 $a$, $b$, $c$($1 ≤ a < b ≤ 10^5$, $0 ≤ c ≤ 9$)。\n\n请输出数字 $c$ 在小数表示中首次出现的位置。位置从紧接小数点后的第 $1$ 位开始编号。如果不存在这样的位置,请输出 _-1_。\n\n第一个示例中的分数的...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ a, b, c \\in \\mathbb{Z} $ with $ 1 \\leq a < b \\leq 10^5 $ and $ 0 \\leq c \\leq 9 $.  \nLet $ x = \\frac{a}{b} $, and let $ d_1, d_2, d_3, \\dots $ be the decimal digits of $ x $ aft...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments