CF900B.Position in Fraction

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You have a fraction . You need to find the first occurrence of digit c into decimal notation of the fraction after decimal point.

你有一个分数 。你需要找出该分数的小数表示中、小数点之后数字 cc 首次出现的位置。

输入格式

The first contains three single positive integers a, b, c (1 ≤ a < b ≤ 105, 0 ≤ c ≤ 9).

第一行包含三个正整数 aa、bb、cc(1 ≤ a < b ≤ 1051 ≤ a < b ≤ 10^5,0 ≤ c ≤ 90 ≤ c ≤ 9)。

输出格式

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.

输出数字 cc 在该分数中小数点后首次出现的位置。位置编号从 1 开始(即小数点后的第一位为位置 1)。若不存在这样的位置,则输出 −1-1。

输入输出样例

  • 输入#1

    1 2 0

    输出#1

    2
  • 输入#2

    2 3 7

    输出#2

    -1

说明/提示

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.

第一个例子中的分数具有如下小数表示:。第一个 0 出现在第二位。

第二个例子中的分数具有如下小数表示:。该分数的小数表示中不包含数字 7。

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

首页