Problem:
Skyland

Somewhere in the sky, KM kingdom built n floating islands by their highly developed technology.
The islands are numbered from 1 to n.

The king of the country, Kita_masa, can choose any non-negative real number as the altitude for each island, as long as the sum of the altitudes is greater than or equals to H.
For floating the island i to the altitude h_i, it costs b_i h_i.
Besides, it costs |h_i - h_j|c_{i,j} for each pair of islands i and j since there are communications between these islands.

Recently, energy prices are rising, so the king, Kita_masa, wants to minimize the sum of the costs.
The king ordered you, a court programmer, to write a program that finds the altitudes of the floating islands that minimize the cost.

Input

The input contains several test cases.
Each test case starts with a line containing two integers n (1 \leq n \leq 100) and H (0\leq H \leq 1,000), separated by a single space.
The next line contains n integers b_1, b_2,..., b_n (0\leq b_i \leq 1,000).
Each of the next n lines contains n integers c_{i,j} (0 \leq c_{i,j} \leq 1,000).
You may assume c_{i, i} = 0 and c_{i, j} = c_{j, i}.

The last test case is followed by a line containing two zeros.

Output

For each test case, print its case number.
Then print a line containing a space-separated list of the altitudes of the islands that minimizes the sum of the costs.
If there are several possible solutions, print any of them.
Your answer will be accepted if the altitude of each island is non-negative, sum of the altitudes is greater than (1-10^{-9})H, and the cost calculated from your answer has an absolute or relative error less than 10^{-9} from the optimal solution.

Follow the format of the sample output.

Sample Input

2 1
1 3
0 1
1 0
3 3
1 2 4
0 2 0
2 0 1
0 1 0
0 0

Output for the Sample Input

Case 1:
0.75 0.25
Case 2:
1.5 1.5 0.0

Solution in C# (judge verdict: Accepted)

using System;
using System.Linq;
using System.Collections.Generic;
//using System.Numerics;
using Debug = System.Diagnostics.Debug;
using SB = System.Text.StringBuilder;
using Number = System.Int64;
namespace Program {
    public class Solver {
        public void Solve() {
            for (int T = 1; ; T++) {
                var n = ri;
                if (n == 0) break;
                var H = ri;
                var b = Enumerate(n, x => ri);
                var c = Enumerate(n, x => Enumerate(n, y => ri));
                var l = 0.0; var r = 1001.0;
                Func<double, bool[]> f = x => {
                    var mf = new MaxFlow.MaxFlow(n + 2);
                    var src = n;
                    var sink = src + 1;
                    for (int i = 0; i < n; i++) {
                        mf.AddDirectedEdge(src, i, b[i]);
                        mf.AddDirectedEdge(i, sink, x);
                        for (int j = 0; j < n; j++)
                            if (i != j)
                                mf.AddDirectedEdge(i, j, c[i][j]);
                    }
                    mf.Execute(src, sink);
                    //Debug.WriteLine($"{res} {n * x}");
                    var q = new Queue<int>();
                    var vis = new bool[n + 2];
                    vis[src] = vis[sink] = true;
                    q.Enqueue(src);
                    while (q.Any()) {
                        var p = q.Dequeue();
                        foreach (var e in mf.G[p])
                            if (e.Cap > 1e-8 && !vis[e.To]) {
                                vis[e.To] = true;
                                q.Enqueue(e.To);
                            }
                    }
                    return vis.Take(n).Select(y => y).ToArray();
                };
                for (int _ = 0; _ < 100; _++) {
                    var m = (l + r) / 2;
                    if (f(m).All(x => x)) l = m;
                    else r = m;
                }
                Debug.WriteLine(r);
                var ans = f(r);
                var cnt = ans.Count(x => !x);
                Console.WriteLine("Case {0}:", T);
                var ss = new string[n];
                for (int i = 0; i < n; i++)
                    ss[i] = !ans[i] ? (1.0 * H / cnt).ToString("0.000000000000") : "0.0";
                Console.WriteLine(ss.AsJoinedString());
            }

        }
        const long INF = 1L << 60;
        //int[] dx = { -1, 0, 1, 0 };
        //int[] dy = { 0, 1, 0, -1 };

        int ri { get { return sc.Integer(); } }
        long rl { get { return sc.Long(); } }
        double rd { get { return sc.Double(); } }
        string rs { get { return sc.Scan(); } }
        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());

        static T[] Enumerate<T>(int n, Func<int, T> f) {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f(i);
            return a;
        }

        static public void Swap<T>(ref T a, ref T b) {
            var tmp = a;
            a = b;
            b = tmp;
        }
    }
}

#region main

static class Ex {
    static public string AsString(this IEnumerable<char> ie) {
        return new string(ie.ToArray());
    }

    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
        return string.Join(st, ie.Select(x => x.ToString()).ToArray());
        //return string.Join(st, ie);
    }

    static public void Main() {
        Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = false });
        var solver = new Program.Solver();
        solver.Solve();
        Console.Out.Flush();
    }
}

#endregion
#region Ex

namespace Program.IO {
    using System.IO;
    using System.Text;
    using System.Globalization;

    public class Printer: StreamWriter {
        public override IFormatProvider FormatProvider {
            get { return CultureInfo.InvariantCulture; }
        }
        public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
    }

    public class StreamScanner {
        public StreamScanner(Stream stream) {
            str = stream;
        }

        public readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream {
            get { return isEof; }
        }

        private byte read() {
            if (isEof) return 0;
            if (ptr >= len) {
                ptr = 0;
                if ((len = str.Read(buf, 0, 1024)) <= 0) {
                    isEof = true;
                    return 0;
                }
            }
            return buf[ptr++];
        }

        public char Char() {
            byte b = 0;
            do b = read(); while ((b < 33 || 126 < b) && !isEof);
            return (char)b;
        }

        public string Scan() {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);
            return sb.ToString();
        }

        public string ScanLine() {
            var sb = new StringBuilder();
            for (var b = Char(); b != '\n' && b != 0; b = (char)read()) if (b != '\r') sb.Append(b);
            return sb.ToString();
        }

        public long Long() {
            return isEof ? long.MinValue : long.Parse(Scan());
        }

        public int Integer() {
            return isEof ? int.MinValue : int.Parse(Scan());
        }

        public double Double() {
            return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture);
        }
    }
}

#endregion
namespace MaxFlow {
    using C = System.Double;

    #region MaxFlow
    public partial class MaxFlow {
        public readonly List<Edge>[] G;
        readonly int[] lv, iter;
        public MaxFlow(int V) {
            G = new List<Edge>[V];
            lv = new int[V];
            iter = new int[V];
            for (int i = 0; i < G.Length; i++)
                G[i] = new List<Edge>();
        }

        public void AddDirectedEdge(int from, int to, C cap) {
            addEdge(from, to, cap, 0);
        }

        public void AddUndirectedEdge(int from, int to, C cap) {
            addEdge(from, to, cap, cap);
        }
        void addEdge(int f, int t, C c1, C c2) {
            var a = new Edge(t, c1);
            var b = new Edge(f, c2);
            Edge.Link(a, b);
            G[f].Add(a);
            G[t].Add(b);
        }


        public C Execute(int src, int sink, C f = -1) {
            C flow = 0;
            if (f < 0) f = C.MaxValue;
            while (f > 0) {
                bfs(src);
                if (lv[sink] == 0) return flow;
                Array.Clear(iter, 0, iter.Length);
                C df;
                while ((df = dfs(src, sink, f)) > 0) {
                    flow += df; f -= df;
                }
            }
            return flow;
        }

        void bfs(int s) {
            Array.Clear(lv, 0, lv.Length);
            var q = new Queue<int>();
            lv[s] = 1;
            q.Enqueue(s);
            while (q.Count > 0) {
                var v = q.Dequeue();
                foreach (var e in G[v])
                    if (e.Cap > 0 && lv[e.To] == 0) {
                        lv[e.To] = lv[v] + 1;
                        q.Enqueue(e.To);
                    }
            }

        }
        C dfs(int v, int t, C f) {
            if (v == t) return f;
            C ret = 0;
            for (; iter[v] < G[v].Count; iter[v]++) {
                var e = G[v][iter[v]];
                if (e.Cap <= 0 || lv[v] >= lv[e.To]) continue;
                C df = dfs(e.To, t, Math.Min(f, e.Cap));
                if (df <= 0) continue;
                e.Cap -= df;
                e.Rev.Cap += df;
                ret += df; f -= df;
                if (f == 0) break;
            }
            return ret;

        }
    }
    public class Edge {
        public static void Link(Edge e1, Edge e2) {
            e1.Rev = e2; e2.Rev = e1;
        }
        public int To { get; private set; }
        public Edge Rev { get; private set; }
        public C Cap { get; set; }
        public Edge(int t, C c) {
            To = t;
            Cap = c;
        }
        public override string ToString() {
            return string.Format("to: {0}, cap: {1}", To, Cap);
        }
    }
    #endregion

}