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()
// }

Python: #coding:utf-8
from __future__ import division,print_function
try:
    input = raw_input
    range = xrange
except NameError:
    pass
# 上記のコードはPython2とPython3の違いを一部吸収するためのもの

# http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=916014

# N * Mの表をつくる.すべての要素はvにする。
def make_matrix(N,M,v):
    # return [[v for i in range(M)] for j in range(N)]とも書ける。
    ret = []
    for i in range(N):
        l = []
        for j in range(M):
            l.append(v)
        ret.append(l)
    return ret


# gは行列(二次元配列)
def solve(n,m,g):
    # current_max[i][j] = 直前がjの場合のi日目の最大成長度
    # 負の数にはなりえない。
    current_max = make_matrix(m,n,-1)
    # 最初は何をあげても1.0のまま
    for i in range(n):
        current_max[0][i] = 1.0
    for i in range(1,m):
        # jは次にあげるもの
        for j in range(n):
            # 前に何をあげてたか
            # current_max[i][j] = max(current_max[i-1][k] * g[k][j]) for k in [0,n]
            for k in range(n):
                current_max[i][j] = max(current_max[i][j],
                                        current_max[i-1][k]*g[k][j])
    ret = max(current_max[m-1])
    ret = round(ret,2)
    print(ret)

def main():
    while True:
        # 受けとった文字列をintに変換する(リストの内包表記)
        n,m = [int(i) for i in input().split(" ")]
        if n == 0 and m == 0:
            return
        g = []
        for i in range(n):
            g.append([float(x) for x in input().split(" ")])

        solve(n,m,g)
main()

Python: # Aizu Problem 0191: Baby Tree
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    n, m = [int(_) for _ in input().split()]
    if n == m == 0:
        break
    rates = [[float(_) for _ in input().split()] for __ in range(n)]
    growth = [[0.] * n for _ in range(m)]
    for k in range(n):
        growth[0][k] = 1.
    for day in range(1, m):
        for current in range(n):
            for previous in range(n):
                growth[day][current] = max(growth[day][current], \
                                    growth[day-1][previous] * rates[previous][current])
    print("%.2f" % max(growth[m-1]))

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

# define MAX_N 100
# define MAX_M 100

int n, m;
double dp[MAX_N][MAX_M];

double board[MAX_M][MAX_M];

int main() {
	while (1) {
		std::cin >> n >> m;
		if (n == 0 && m == 0)
			break;
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < m; ++j)
				dp[i][j] = 0;
		for (int i = 0; i < m; ++i) {
			for (int j = 0; j < m; ++j)
				std::cin >> board[i][j];
		}
		std::fill(dp[0], dp[0] + m, 1.0);
		for (int i = 1; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				for (int k = 0; k < m; ++k) {
					dp[i][j] = std::max(dp[i][j], dp[i - 1][k] * board[k][j]);
				}
			}
		}
		double res = 0;
		for (int i = 0; i < m; ++i)
			res = std::max(res, dp[n - 1][i]);
		std::cout << std::fixed << std::setprecision(2) << res << std::endl;
	}
	return 0;
}

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++) {
                fill(tmp[0], tmp[N], 0);
                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 << round(ans) / 100.0 << endl;
        }
    }
    return 0;
}

C++: #include "stdio.h"

int n;
int m;
double p[100][100];
double dp[101][100];//i回目にjを使った時の最大の倍率

double ans = -1;

int max(int a,int b){if(a>b)return a;else return b;}

int main(){

	while(1){

		scanf("%d %d",&n,&m);

		if(n==0&&m==0){
			break;
		}

		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				scanf("%lf",&p[i][j]);
			}
		}

		ans = 0;

		for(int i=1;i<=m;i++){
			for(int j=0;j<n;j++){
				dp[i][j] = 0;
			}
		}

		for(int i=0;i<n;i++){
			dp[1][i] = 1.000;
		}

		for(int i=2;i<=m;i++){
			for(int j=0;j<n;j++){
				for(int k=0;k<n;k++){
					dp[i][j] = max(dp[i][j],dp[i-1][k] * p[k][j]);
					
				}
			}
		}

		for(int i=0;i<n;i++){
			ans = max(dp[m][i],ans);
		}
		


		printf("%.2lf\n",ans);

	}

	return 0;

}