Go: // n×nの成長度表に現れる数字を重複を許してm-1個選んで掛け合わせる時の最大値を求める
// ->掛け算型のDP

package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
		"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan(){
		buf := strings.Split(scanner.Text(), " ")
		n, _ := strconv.Atoi(buf[0])
		m, _ := strconv.Atoi(buf[1])
		if n == 0 && m == 0 {
			break
		}
		growth_table := make([][]float64, n)
		for i := range growth_table {
			scanner.Scan()
			buf_ := strings.Split(scanner.Text(), " ")
			tmp := make([]float64, n)
			for j := range tmp {
				tmp[j], _ = strconv.ParseFloat(buf_[j], 64)
			}
			growth_table[i] = tmp
		}
		dp := make([][]float64, m)
		for i := range dp {
			dp[i] = make([]float64, n)
		}
		for i := range dp {
			dp[0][i] = 1
		}
		for k := 1; k < m; k++ {
			// k個使うとき...
			for i := 0; i < n; i++ {
				for j := 0; j < n; j++ {
					// 新たにgrowth_table[i][jを使うかどうか
					dp[k][j] = max(dp[k][j], dp[k-1][i]*growth_table[i][j])
					// check(dp)
				}
			}
		}
		ans := 0.0
		for i := 0; i < n; i++ {
			if dp[m-1][i] > ans {
				ans = dp[m-1][i]
			}
		}
		fmt.Printf("%.2f\n", ans)
	}
}

func max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

// func check(dp [][]float64) {
// 	log.Println()
// 	for i := range dp {
// 		log.Println(dp[i])
// 	}
// 	log.Println()
// }

C++: // 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

const pair<int, int> NIL(-1, -1);

double mat[110][110], tmp[110][110];
 
signed main() {
    int N, M;
    while(cin >> N >> M, N) {
        for(int i=0; i<N; i++) {
            for(int j=0; j<N; j++) {
                cin >> mat[i][j];
            }
        }

        cout << fixed << setprecision(2);
        if(M == 1) cout << 1.0 << endl;
        else {
            for(int k=0; k<M-2; k++) {
                for(int j=0; j<N; j++) {
                    double ma = -1;
                    for(int i=0; i<N; i++) {
                        chmax(ma, mat[i][j]);
                    }
                    for(int i=0; i<N; i++) {
                        chmax(tmp[j][i], mat[j][i] * ma);
                    }
                }
                swap(mat, tmp);
            }

            double ans = -1;
            for(int i=0; i<N; i++) {
                for(int j=0; j<N; j++) {
                    chmax(ans, mat[i][j] * 100);
                }
            }
            cout << (int)(ans + 0.5) / 100.0 << endl;
        }
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n, m;
	long double r, a[101][101], dp[101][101];
	
	while(cin>>n>>m && (m+n)){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin >> a[i][j];
			}
		}
		fill(&dp[0][0], &dp[100][100], 0);
		
		for(int i = 0; i < n; i++){
			dp[i][0] = 1.0;
		}
		
		for(int k = 1; k < m; k++){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					dp[i][k] = max(dp[i][k], dp[i][k-1]*a[j][i]);
				}
			}
		}
		
		r = 0.0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				r = max(r, dp[i][j]);
			}
		}
		
		printf("%.2f\n", r);
	}
	
	return 0;
}

C++: 
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
    
#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)
    
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)


using namespace std;


int main(void){
    
    int drugnumber;
    int drugcounter;
    /* x????¨????,y?????´????????? */
    double drugeffect[120][120] = {0};
    int i,j,k,l;
    double max = 0;
    double answer[100] = {0};
    
    while(cin >> drugnumber >> drugcounter,drugnumber+drugnumber)
    {
        double combination[120][120] = {0};
        /*??£??\*/
        FOR(j, 1, drugnumber+1)
        FOR(i, 1, drugnumber+1)
        cin >> drugeffect[j][i];
        
        //cout << drugeffect[2][1];
        
        for(k = 1;k <= drugnumber; k++)
            combination[1][k] = 1.0;
        //cout << combination[1][2] << endl;
        
        /* j?????¬?????°,i????????°*/
        
        for(i = 1; i< drugcounter;i++)
            for(j = 1; j<= drugnumber;j++)
            {
                for(k = 1; k<=drugnumber;k++)
                {
                    if((combination[i][j] * drugeffect[j][k]) >= combination[i+1][j])
                        combination[i+1][j] = combination[i][j]*drugeffect[j][k];
                     //cout << combination[i+1][j] << " ";
                    /*
                     if((combination[j][i] * drugeffect[j][i]) >= combination[j][i])
                     combination[j][i+1] = combination[j][i] * drugeffect[j][i];
                     */
                }
            }
        
    
    for(i = 1 ; i<= drugnumber;i++)
        if(max <  combination[drugcounter][i])
            max = combination[drugcounter][i];
    
        answer[l] = max;
        max = 0;
        l++;
        
    }
    
    REP(i,l)
    printf("%.2f\n",answer[i]);
    return 0;
    
}

C++: #include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;

double g[101][101];
double dp[101][101];

int main(){
	int n,m;
	while(cin>>n>>m){
		if(n==0&&m==0)  break;
		for(int i=0; i<=m; ++i){
			for(int j=0; j<n; ++j){
				dp[i][j]=0;
			}
		}
		for(int i=0; i<n; ++i){
			for(int j=0; j<n; ++j){
				cin >> g[i][j];
			}
		}
		for(int i=0; i<n; ++i){
			dp[1][i]=1.00;
		}
		for(int i=2; i<=m; ++i){
			for(int j=0; j<n; ++j){
				double tmp=dp[i][j];
				for(int k=0; k<n; ++k){
					tmp=max(tmp,dp[i-1][k]*g[k][j]);
				}
				dp[i][j]=tmp;
			}
		}
		double ans=0;
		for(int i=0; i<n; ++i){
			ans=max(ans,dp[m][i]);
		}
		//ans=((int)(ans*100+0.5))/100;
		//ans=int(ans*100+0.5);
		//ans/=100;
		printf("%.2f\n",ans);
	}
	return 0;
}