1  // Fly Swatter                             Bill Rubin
   2  using System;
   3  using System.IO;
   4  using System.Diagnostics;
   5  
   6  class Program {
   7  
   8  [STAThread]
   9  static void Main(string[] args)	{
  10  	try {
  11  		// Read N
  12  		StreamReader reader = new StreamReader(args[0]);
  13  		int N = Convert.ToInt32(reader.ReadLine());
  14  
  15  		// Open output file:
  16  		string filename = System.IO.Path.GetFileNameWithoutExtension(args[0]);
  17  		TextWriter tw = new StreamWriter(filename + ".txt");
  18  
  19  		// For each case, read input file, process, and write output file:
  20  		for(int i = 1; i<=N; ++i) {
  21  			// Read and parse problem:
  22  			string problem = reader.ReadLine();
  23  			string[] parts = problem.Split(' ');
  24              Debug.Assert(parts.Length==5, "Unexpected input");
  25  
  26  			string fs = parts[0];
  27  			string Rs = parts[1];
  28  			string ts = parts[2];
  29  			string rs = parts[3];
  30  			string gs = parts[4];
  31  
  32  			double f = Convert.ToDouble(fs);
  33  			double R = Convert.ToDouble(Rs);
  34  			double t = Convert.ToDouble(ts);
  35  			double r = Convert.ToDouble(rs);
  36  			double g = Convert.ToDouble(gs);
  37  
  38  			// Execute test case, and output result:
  39  			TestCase testCase = new TestCase(f, R, t, r, g);
  40  			testCase.execute();
  41              Double probability = testCase.getProbability();
  42              tw.WriteLine("Case #" + i + ": " + probability.ToString("0.000000"));
  43  		    }
  44  		tw.Close();
  45  		reader.Close();
  46  	    }
  47  	catch(Exception x) {Console.Write(x.Message.ToString());}
  48  }
  49  
  50  }