Pagini recente » Cod sursa (job #2855950) | Cod sursa (job #2791883) | Cod sursa (job #511313) | Cod sursa (job #3197635) | Cod sursa (job #1527257)
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;
ifstream fin( "prod.in" ); ofstream fout( "prod.out" );
typedef vector< int > huge;
const int base = 10;
int f[ base ];
huge a, b;
bool operator < ( const huge &x, const huge &y ) {
if( x.size() != y.size() ) {
return ( x.size() < y.size() );
}
if ( x.size() == 0 ) return 1;
int j = ( int )x.size() - 1;
while ( j > 0 && x[ j ] == y[ j ] ) {
-- j;
}
return ( x[ j ] < y[ j ] );
}
huge operator * ( const huge &x, const huge &y ) {
huge z;
z.resize( ( int )x.size() + ( int )y.size() - 1, 0 );
for( int i = 0; i < ( int )x.size(); ++ i ) {
for( int j = 0; j < ( int )y.size(); ++ j ) {
z[ i + j ] += x[ i ] * y[ j ];
}
}
int t = 0;
for( int i = 0; i < ( int )z.size() || t != 0; ++ i ) {
if ( i == ( int )z.size() ) {
z.push_back( 0 );
}
z[ i ] += t;
t = z[ i ] / base;
z[ i ] %= base;
}
return z;
}
int main() {
int sum = 0;
for( int i = 1; i <= 9; ++ i ) {
fin >> f[ i ];
sum += f[ i ];
}
int j = 9;
for( int i = 0; i < sum; ++ i ) {
while ( f[ j ] == 0 ) {
-- j;
}
if ( a < b ) {
a.push_back( j );
} else {
b.push_back( j );
}
-- f[ j ];
}
reverse( a.begin(), a.end() );
reverse( b.begin(), b.end() );
a = a * b;
for( int i = ( int )a.size() - 1; i >= 0; -- i ) {
fout << a[ i ];
}
fout << "\n";
fin.close();
fout.close();
return 0;
}