Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Time limit is exceeded

$
0
0

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.


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>