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

package main

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

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 <algorithm>

using namespace std;

int main()
{
	int n, m, c[100], p;
	double a[100][100], b[100], max;
	
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0){
			break;
		}
	
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin >> a[i][j];
			}
			c[i] = i;
		}
		fill(b, b+n, 1.0);
	
		for(int k = 1; k < m; k++){
			for(int i = 0; i < n; i++){
				max = 0.0;
				for(int j = 0; j < n; j++){
					if(max < a[c[i]][j]){
						max = a[c[i]][j];
						p = j;
					}
				}
				b[i] *= max;
				c[i] = p;
			}
		}
		sort(b, b+n);
		max = b[n-1]*100-(int)b[n-1]*100;
		max = (int)max*10;
		if(max >= 5){
			b[n-1] += 0.01;
		}
		
		printf("%.2f\n", b[n-1]);
	}
	
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
	double memo[100][100];
	double data[100][100];
	int n, m;

	while (true)
	{
		cin >> n >> m;
		if (n == 0) return 0;

		for (int i = 0; i < n; i++){
			for (int j = 0; j < m; j++){
				memo[i][j] = -1;
				if (i == 0) memo[i][j] = 1.0;
			}
		}

		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				cin >> data[i][j];
			}
		}

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

		double Max = 0;
		for (int i = 0; i < n; i++)
		{
			Max = max(Max, memo[m - 1][i]);
		}
		printf("%.2f\n", Max);
	}

	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b,a||b){
    vector<vector<double> >in(a,vector<double>(a));
    rep(i,a)rep(j,a)cin>>in[i][j];
    vector<vector<double> >out(b,vector<double>(a));
    rep(i,a)out[0][i]=1.0;
    rep(i,b-1){
      rep(j,a){
	double max1=0;
	rep(k,a)if(max1<out[i][k]*in[k][j])max1=out[i][k]*in[k][j];
	out[i+1][j]=max1;
      }
    }
    double max1=0;
    rep(i,a)if(max1<out[b-1][i])max1=out[b-1][i];
    //double tmp=max1*100-(int)(max1*100);
    //printf("%.3f\n",tmp);
    //if(tmp-0.50>=-ESP)max1+=0.01;
    printf("%.2f\n",max1);
  }
}

C++: 
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  int n,m;
  while(1){
    cin>>n>>m;
    if(n==0 && m==0)break;
    m--;
    double v[100][100];
    rep(i,n)rep(j,n)cin>>v[i][j];
    double dp[105][105];
    rep(i,n) dp[0][i]=1;
    loop(i,1,m+1)rep(j,n){
      dp[i][j]=0;
      rep(k,n)
	dp[i][j]=max(dp[i][j],dp[i-1][k]*v[k][j]);
 
    }
    double ans=0;
    rep(i,n)ans=max(ans,dp[m][i]);
    cout<<shosu(2)<<ans<<endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int n,m;
double g[100][100],dp[2][100],M;

int main(){
	while(cin>>n>>m&&m){
		rep(i,n)rep(j,n)cin>>g[i][j];
		rep(i,m){
			rep(j,n){
				if(!i)dp[1][j]=1;
				else{
					M=0;
					rep(k,n)M=max(M,dp[0][k]*g[k][j]);
					dp[1][j]=M;
				}
			}
			rep(j,n)dp[0][j]=dp[1][j];
			//rep(j,n)cout<<dp[0][j]<<(j<n-1?" ":"\n");
		}
		M=0;
		rep(i,n)M=max(M,dp[0][i]);
		printf("%.2f\n",M);
	}
}

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--)


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][k])
                        combination[i+1][k] = 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;
    
}