Cod sursa(job #1435909)

Utilizator OpportunityVlad Negura Opportunity Data 14 mai 2015 19:11:31
Problema Multiplu Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <fstream>
using namespace std;

ifstream fi("multiplu.in");
ofstream fo("multiplu.out");

long long a,b,xa,xb;

int is01(long long x) {
	while (x) {
		if (x % 10 > 1) {
			return 0;
		}
		x /= 10;
	}

	return 1;
}


int main() {
	fi >> a >> b;

	for (long long i = 2; i < min(a,b)/2+1; i++) {
		if (!(a % i) && !(b % i)) {
			a /= i;
			b /= i;
		}
	}

	while (xa*xb < 2000000) {
		xa += a;
		while (xa*xb < 2000000) {
			xb += b;
			if (is01(xa*xb)) {
				fo << xa*xb;
				return 0;
			}
		}
	}

	return 0;
}