<?php
$test1 = array(10,5);
	$test2 = array([0,0.3],[0.2,0]);
	
	$l = count($test1);	
	$c = array();
	$c = iniArray($c, 19);
	$c = calFactor($test1,$test2, $l);
	echo "<br><br> enddd<br>";
	echo json_encode($c);
	
function calFactor( $factorList, $relationList, $l)
{	
	$temp  = array();
	$temp = iniArray($temp, $l);
	$final = array();
	$final = iniArray($final, $l);
	$flag2 = 0;	
	
	for($i=0; $i < $l ; $i++)
	{
		if($factorList[$i]==0)
			continue;
		else
		{
			$flag2 = 1;
			$partFactorList = array();
			$partFactorList = checkArray($factorList[$i],$i ,$l);
			
			$temp = countFactor($partFactorList, $relationList, $l, $i);
			$checkzero = check($temp, $l);
			if($checkzero == 0)
			{
				$flag2 = 0;
				continue;
			}
				
			else
			{
				for($j= 0; $j <$l; $j++)
					$final[$j] += $temp[$j];				
			}
		}
	}
	if($flag2==0)
		return $factorList;
	else
		return $final;
	
}
function countFactor($factorList, $relationList, $l, $ptr)
{
	$countFactorTemp = array();
	$countFactorTemp = iniArray($countFactorTemp, $l);
	$countFactorTemp2 = array();
	$countFactorTemp2 = iniArray($countFactorTemp2, $l);
	$flag = 0;
	for($j = 0; $j < $l; $j++)
	{	
		$num = $factorList[$ptr]*$relationList[$ptr][$j];		
		if( $num < 0.1)
			$countFactorTemp[$j]=0;
		else
		{			
			$countFactorTemp[$j] = round($num *100)/100;			
			$flag = 1;
		}
	}			
	if($flag ==0)
	{
		$arr = array();
		$arr = iniArray($arr, $l);
		return $arr;
	}
	else
	{		
		$countFactorTemp2 = calFactor($countFactorTemp, $relationList, $l);		
		for($j= 0; $j <$l; $j++)
		{
			$countFactorTemp2[$j] += $factorList[$j];
		}		
		return $countFactorTemp2;
	}
}	
function iniArray($arr,$length)
{
	$i;

	for( $i= 0; $i< $length; $i++)
	{
		$arr[$i]=0;	
	}	
	return $arr;
}
function checkArray($arr,$j ,$l)
{
	$temp = array();
	for ( $k = 0; $k < $l; $k++)
	{
		if($k==$j)
			$temp[$k] = $arr;
		else
			$temp[$k]=0;
	}
	return $temp;
}

function check($arr, $l)
{
	for($i=0; $i< $l; $i++)
	{
		if($arr[$i]!=0)
			break;
	}
	if($i != $l)
		return 1;
	else 
		return 0;
}
?>
// your code goes here