Cod sursa(job #118318)

Utilizator sima_cotizoSima Cotizo sima_cotizo Data 24 decembrie 2007 14:48:18
Problema Multiplu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.96 kb
#include <cstdio>
#include <string>
#include <queue>
#include <utility>
using namespace std;

long A,B,M;

long cmmdc(long a, long b) {
	if ( a<b ) { long r = a; a = b; b = r; }
	while ( b ) { long r = a%b; a=b; b=r; }
	return a;
}

queue < long > Q;
pair<bool, string> V[20000101];

int main() { 
	fscanf(fopen("multiplu.in", "r"), "%ld %ld", &A, &B);
	return 0;

	M = A*B / cmmdc(A,B);
	Q.push( 1 ); V[1].first = true; V[1].second = "1";
	while ( !Q.empty() ) {
		pair <string, long> x;
		x.second = Q.front(); Q.pop();
		x.first = V[x.second].second;
		if ( !V[(x.second*10) % M].first ) {
			Q.push((x.second*10)%M);
			V[(x.second*10)%M].first = true;
			V[(x.second*10)%M].second = x.first+"0";
		}
		if ( !V[(x.second*10+1) % M].first ) {
			Q.push((x.second*10)%M);
			V[(x.second*10+1)%M].first = true;
			V[(x.second*10+1)%M].second = x.first+"1";
		}
		if ( V[0].first ) 
			break;
	}
	
	fprintf(fopen("multiplu.out", "w"), "%s", V[0].second.c_str());
	return 0;
}