Pagini recente » Cod sursa (job #1548997) | Istoria paginii runda/olimpiada_info/clasament | Cod sursa (job #2098892) | Cod sursa (job #2759403) | Cod sursa (job #1226613)
#include <bits/stdc++.h>
#define VI vector<int>
#define VII vector<pair<int,int>>
#define QI queue<int>
#define ms(a,v) memset( a, v, sizeof( a ) )
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define ROF(i,a,b) for(int i = a; i >= b; i--)
#define foreach(v, c) for( typeof( (c).begin() ) v = (c).begin(); v != (c).end(); ++v)
#define pb push_back
#define pp pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define popcount __builtin_popcount
#define gcd __gcd
#define bit(n,i) ( n & ( 1LL << i ) )
#define lsb(x) ( x & ( -x ) )
#define FIN(str) freopen(str,"r",stdin)
#define FOUT(str) freopen(str,"w",stdout)
#define Fin(str) ifstream(str)
#define Fout(str) ostream(str)
#define SYNC ios_base::sync_with_stdio(0);
#define ll long long
#define ull unsigned long long
inline void read( int &a )
{
register char ch;
a = 0;
int sign = 1;
do
{
ch = getchar();
} while ( !isdigit( ch ) && ch != '-' );
if ( ch == '-' )
{
sign = -1;
ch = getchar();
}
do
{
a = a * 10 + ch - '0';
ch = getchar();
} while( isdigit( ch ) );
a *= sign;
}
inline void write( int a )
{
char s[20];
int i = 0;
int sign = 1;
if ( a < 0 )
sign = -1,
a = -a;
do
{
s[ i++ ] = a % 10 + '0';
a /= 10;
} while ( a );
i--;
if ( sign == -1 )
putchar( '-' );
while ( i >= 0 ) putchar( s[ i-- ] );
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };
const int dl[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
const int dc[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int INF = 2e9;
const double EPS = 1e-9;
const int Nmax = 2e6 + 2;
const int LgMax = log2(Nmax) + 1;
using namespace std;
int cif[Nmax];
int tata[Nmax];
int rest[Nmax];
int D[Nmax];
queue <int> Q;
void afis( int nr )
{
if ( tata[nr] != -1 )
afis( tata[nr] );
cout << cif[nr];
}
int main()
{
FIN("multiplu.in");
FOUT("multiplu.out");
int A, B, C;
cin >> A >> B;
C = A * B / gcd( A, B );
ms( D, 0x3f );
Q.push( 1 );
D[1] = 0;
cif[1] = 1;
tata[1] = -1;
while ( Q.size() )
{
int nod = Q.front();
Q.pop();
for ( int i = 0; i <= 1; ++i )
{
int aux = ( ( nod * 10 ) + i ) % C;
if ( D[aux] > D[nod] + 1 )
{
D[aux] = D[nod] + 1;
cif[aux] = i;
tata[aux] = nod;
Q.push( aux );
}
}
}
afis( 0 );
return 0;
}