1.


/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 10106 Product
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=13&page=show_problem&problem=1047
*
* @author Anton Pavlushko, IBB7B,
* @version 1.0, 10/10/2010
*
* Status : Accepted
* Runtime: 0.436
*/

import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String current_line2, current_line, empty = "";
int number, factorial, i, j, length, number_local, length_1, length_2, k;
int primes [], counts [], current_multiply;
double znak,count5,count5_already,multiply;
StringTokenizer input_string;
boolean status, at_least_one;
int first[], second[], result[];

try {
while ((current_line=in.readLine())!= null && !current_line.equals("0") &&
(current_line2=in.readLine())!= null) {
current_line=current_line.trim();
current_line2=current_line2.trim();

first = new int[251];
second = new int[251];
result = new int[502];

length_1=current_line2.length();
for(i=length_1-1;i>=0;i--) {
second[length_1-i] = Integer.parseInt(current_line2.substring(i,i+1));
}

length_2=current_line.length();
for(i=length_2-1;i>=0;i--) {
first[length_2-i] = Integer.parseInt(current_line.substring(i,i+1));
}

if (!current_line.equals("0") && !current_line2.equals("0"))
for(i=1;i<=length_1;i++) {

for(j=1;j<=length_2;j++) {
k=first[j]*second[i];

result[i+j-1]+=k%10;
result[i+j]+=k/10;

length=result.length;

do {
number=0;
for(k=0;k<length;k++) {
if (result[k]>=10) {
result[k+1]+=result[k]/10;
result[k]=result[k]%10;
number++;
}
}
} while (number>0);
}
}

length=result.length;
empty="";
status=false;
for(i=length-1;i>0;i--) {
if (result[i]>0) status=true;
if (status) empty=empty+result[i];
}

if (current_line.equals("0") || current_line2.equals("0"))
System.out.println("0");
else
System.out.println(empty);
} // end while
} // end try
catch (IOException e) {
System.err.println("Error: " + e);
}
}
}


2.

/**
* ACM Training 2010
* ACM Problem #10106 - Product
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=13&problem=1047&mosmsg=Submission+received+with+ID+7886373
*
* @author Felix Dietrich
* @version 1.0, 04/09/2010
*
* Methode: BigInteger
* Status : Accepted
* Runtime: 0.144
*/

import java.math.BigInteger;
import java.util.*;

public class Main
{
public static void main(String... strs)
{
Scanner sc = new Scanner(System.in);

while(sc.hasNext())
{
BigInteger s1 = new BigInteger(sc.next());
BigInteger s2 = new BigInteger(sc.next());

System.out.println(s1.multiply(s2).toString());
}
}
}