-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathsumdigi.cpp
More file actions
46 lines (44 loc) · 959 Bytes
/
sumdigi.cpp
File metadata and controls
46 lines (44 loc) · 959 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
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,n;
cin>>a>>b>>n;
if(b>10){
bool check=false;
int j=0;
for( j=0;j<10;j++){
long k=a*10+j;
if(k%b==0){
check=true;
break;
}}
if(check) {
cout<<a<<j;
for(int i=1;i<n;i++){
cout<<0;
} }
else cout<<"-1";
}
else if(b==10){
cout<<a;
for(int i=0;i<n;i++){
cout<<0;
}
}
else{
cout<<a;
for(int i=0;i<n;i++){
if(!i){
for(int j=0;j<10;j++){
long k=a*10+j;
if(k%b==0){
cout<<j;
break;
}
}
}
else cout<<b;
}
}
return 0;
}