# CodeForces 260A Adding Digits 模拟

#include <cstdio>
int a, b, n;
int num[100001];
void dfs(int x, int d) {
if (x > n) {
printf("%d", a);
for(int i=1;i<=n;i++) printf("%d", num[i]);
throw 1;
} else
for(int i=0;i<10;i++)
if((d*10+i)%b==0) num[x]=i,dfs(x+1,0);
}
int main() {
scanf("%d%d%d", &a, &b, &n);
try {
dfs(1,a);
printf("-1");
} catch(int x) {
}
return 0;
}

time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Vasya has got two number: a and b. However, Vasya finds number a too short. So he decided to repeat the operation of lengthening number a n times.

One operation of lengthening a number means adding exactly one digit to the number (in the decimal notation) to the right provided that the resulting number is divisible by Vasya's number b. If it is impossible to obtain the number which is divisible by b, then the lengthening operation cannot be performed.

Your task is to help Vasya and print the number he can get after applying the lengthening operation to number a n times.

Input

The first line contains three integers: a, b, n (1 ≤ a, b, n ≤ 105).

Output

In a single line print the integer without leading zeros, which Vasya can get when he applies the lengthening operations to number a n times. If no such number exists, then print number -1. If there are multiple possible answers, print any of them.

Sample test(s)
input
5 4 5
output
524848
input
12 11 1
output
121
input
260 150 10
output
-1

• 本文已收录于以下专栏：

### 相关文章推荐

A. Adding Digits time limit per test 2 seconds memory limit per test 256 megabytes Vasy...

## 精选：深入理解 Docker 内部原理及网络配置

**A. Adding Digits** time limit per test2 seconds memory limit per test256 megabytes inputstandar...

## 【codeforces 509C】Sums of Digits

【题目链接】:http://codeforces.com/contest/509/problem/C【题意】 给你一个数组b[i] 要求一个严格升序的数组a[i]; 使得a[i]是b[i]各...

## CodeForces 754B（模拟）

B. Ilya and tic-tac-toe game time limit per test 2 seconds memory limit per test 256 megabyt...

## codeforces 676b 模拟

http://codeforces.com/problemset/problem/676/B Mary has just graduated from one...

## CodeForces 118C 【模拟】

举报原因： 您举报文章：深度学习：神经网络中的前向传播和反向传播算法推导 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)