-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlength_number.cpp
More file actions
42 lines (41 loc) · 835 Bytes
/
Copy pathlength_number.cpp
File metadata and controls
42 lines (41 loc) · 835 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
#include <iostream>
using namespace std;
int main()
{
long long a, b, n;
cin >> a >> b >> n;
long long p;
long long c = a;
long long count = 0;
long long flag = 0;
for (int j = 0; j < n; j++)
{
if (flag != 1)
c = c * 10;
p = 0;
for (int i = 0; i <= 9; i++)
{
c = c + p;
if (c % b == 0)
{
if (flag == 0)
{
flag = 2;
cout << c;
count++;
break;
}
flag = 1;
cout << 0;
count++;
break;
}
p = 1;
}
if (flag == 0)
break;
}
if (flag == 0)
cout << "-1\n";
return 0;
}