/**
 * @(#)IntegerMultiplication.java
 *
 *
 * @author :alaa hamda
 * @version 1.00 2011/3/8
 */


public class IntegerMultiplication {

   public static void main(String[]args){
   byte a=11;
   byte b=10;
  
   	Multiplication(a,b);
   }
   //to found the max digit between this two number
   public static  int max(byte number1,byte number2)
   {   Byte xx=new Byte(number1);
  	   int x= xx.intValue();
  	   Byte yy=new Byte(number2);
  	   int y= yy.intValue();
  	   
        String s1= String.valueOf(x);
      String s2= String.valueOf(y);
  
       if(s1.length()>s2.length())
        	return s1.length();
       else
         	return s2.length();
    	
   }
   public static int leftMost(byte  x){
   		Byte xx=new Byte(x);
  	    xx.intValue();
  String s1= String.valueOf(xx);
  
  String s2=s1.substring(0,s1.length()/2);
  Integer xl=Integer.parseInt(s2);
  return xl.byteValue();
 
   }
 public static byte  rightMost(byte  x){
   		Byte xx=new Byte(x);
  	    xx.intValue();
  String s1= String.valueOf(xx);
  
  String s2=s1.substring((s1.length()/2+1));
  
   Integer xl=Integer.parseInt(s2);
  return xl.byteValue();
    
 
   }
   
   
  public static int Multiplication(byte x,byte y) {
 int n; 	
 byte  xl,xr,yl,yr;
 byte p1,p2,p3;
 
   n = max(x,y);
    if(n==1) 
     return x*y;

  else{
  

   xl=leftMost(x);
   xr=rightMost(x); 
   yl=leftMost(y);
   yr=rightMost(y);
   
   p1 = Multiplication(xl,yl);
   p2 = Multiplication(xr,yr) ;
   p3 = Multiplication(xl+xr,yl+yr);

return 2^n*p1 + 2^(n/2)*(p3-p1-p2) + p2; 
  } 

}
}