forked from anshuman8800/Interivew-Questions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdding_Digits.cpp
More file actions
53 lines (47 loc) · 930 Bytes
/
Adding_Digits.cpp
File metadata and controls
53 lines (47 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*https://codeforces.com/problemset/problem/260/A*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll M = 1e9 + 7;
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define endl "\n"
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
{
ll a, b, n;
cin >> a >> b >> n;
int i = 0;
a *= 10;
int flag = 0;
while (i <= 9)
{
a += i;
if (a % b == 0)
{
flag = 1;
break;
}
a -= i;
i++;
}
if (flag == 0)
cout << "-1" << endl;
else
{
string s = to_string(a);
while (n - 1)
{
s += '0';
n--;
}
cout << s << endl;
}
}
return 0;
}