Time limit is exceeded

Hi,

I have written the following code in PHP for problem http://www.codechef.com/problems/A4/

while(FALSE !== ($t = fgets(STDIN))) {
	$n = array();
	$k = array();

	for($i = 0; $i < $t; $i++) {
		list($n[], $k[]) = explode(' ', fgets(STDIN));
	}
	for($i = 0; $i < $t; $i++) {
		$pow_res = bcpow($n[$i], $n[$i]);
		printf("%d %d\n", substr($pow_res, 0, intval($k[$i])), substr($pow_res, strlen($pow_res)-$k[$i]));
	}
}

However I get time limit exceeded. Please help me to optimize it.

use function set_time_limit()

Place this at the top of your PHP script and let your script loose!
ini_set(‘max_execution_time’, 300); //300 seconds = 5 minutes

you can use any of the two methods 
   $i = time depending upon the code you are executing. 60 sec = 1 min
1) ini_set('max_execution_time', $i);
2) You can change the  max_execution_time in php.ini, like this:
   max_execution_time = 360     // which is 6 min = 360
   max_input_time = 120         
   max_input_nesting_level = 64
   memory_limit = 128M

are you sure this should be the output http://ideone.com/5YOVrk ???