Cod sursa(job #3278371)
| Utilizator | Data | 19 februarie 2025 16:39:22 | |
|---|---|---|---|
| Problema | Multiplu | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.68 kb |
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
const int N = 1<<6;
bool vizitat[N];
int cmmdc(int a, int b){
while(b!=0){
int r = a%b;
a=b;
b=r;
}
return a;
}
int main(){
int a, b;
cin>>a>>b;
int m = a*b/cmmdc(a, b);
queue <int> q;
q.push(1);
int k;
while(!q.empty()){
k = q.front();
q.pop();
if(!vizitat[k]){
vizitat[k]=1;
if(k%m==0){
break;
}
q.push(k*10);
q.push(k*10+1);
}
}
cout << k;
return 0;
}