Cod sursa(job #1092798)
| Utilizator | Data | 27 ianuarie 2014 13:57:34 | |
|---|---|---|---|
| Problema | Multiplu | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream f("multiplu.in");
ofstream g("multiplu.out");
long long a, b, rez;
bool valid(long long x)
{
bool rez = true;
for(; x && rez; x /= 10)
{
if(x%10 > 1)
rez = false;
}
return rez;
}
long long calc(long long prod)
{
int i = 1;
for(;;)
{
prod *= i;
if(valid(prod))
break;
else
prod /= i, i++;
}
return prod;
}
int main ()
{
f >> a >> b;
g << calc(a * b);
}
