[Python_Training] Bài toán AFC

View as PDF



Problem type
Allowed languages
C#, C++, Clang, Clang++, Cobol, D, Groovy, Haskell, Java, JS, Kotlin, Lua, Node JS, ObjectiveC, OCaml, Output, PHP, Prolog, Pypy, Pypy 3, Python, Ruby, Rust, Scala, Scratch, Swift
Points: 500 Time limit: 2.0s Memory limit: 256M Input: stdin Output: stdout
  • Cho \(3\) số nguyên \(A,F,C\).

Yêu cầu: Tìm số \(B\) nhỏ nhất thỏa mãn những điều kiện sau:

  • \(B>A\)
  • Số lần xuất hiện chữ số \(C\) trong \(B\) đúng bằng \(F\)

Input

  • Một dòng duy nhất chứa \(3\) số nguyên \(A,F,C(1\le A\le 10^{17}-1 ; 1\le F\le 17 ; 0\le C\le 9)\)

Output

  • In ra số \(B\) cần tìm

Example

Test 1

Input
7 1 7
Output
17

Test 2

Input
12 2 1
Output
101

Comments

There are no comments at the moment.