codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

900B.md (1226B)


      1 Source: https://codeforces.com/problemset/problem/900/B
      2 
      3 B. Position in Fraction
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 You have a fraction ![](https://espresso.codeforces.com/a7487d7e62f90136b78ae3fbf0a008396f146e13.png). You need to find the first occurrence of digit *c* into decimal notation of the fraction after decimal point.
     22 
     23 Input
     24 
     25 The first contains three single positive integers *a*, *b*, *c* (1 ≤ *a* < *b* ≤ 105, 0 ≤ *c* ≤ 9).
     26 
     27 Output
     28 
     29 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.
     30 
     31 Examples
     32 
     33 Input
     34 
     35 ```
     36 1 2 0
     37 ```
     38 
     39 Output
     40 
     41 ```
     42 2
     43 ```
     44 
     45 Input
     46 
     47 ```
     48 2 3 7
     49 ```
     50 
     51 Output
     52 
     53 ```
     54 -1
     55 ```
     56 
     57 Note
     58 
     59 The fraction in the first example has the following decimal notation: ![](https://espresso.codeforces.com/896357459a466614a0542f34c9cfb0cef1afc9ed.png). The first zero stands on second position.
     60 
     61 The fraction in the second example has the following decimal notation: ![](https://espresso.codeforces.com/130ba579a8276fc53a1917606eee9db58817f28d.png). There is no digit 7 in decimal notation of the fraction.