Contest Duration: ~ (local time) (120 minutes) Back to Home

Submission #169791

Source Code Expand

Copy
```using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
class Program
{
static void Main()
{
var sc = new Scanner();
var n = sc.Integer();
var c = sc.IntArray(n);
var ar = new int[n];
for (int i = 0; i < n; i++)
{
for (int j = i+1; j < n; j++)
{
if (c[i] % c[j] == 0)
ar[i]++;
if (c[j] % c[i] == 0)
ar[j]++;
}
}
var ret=0.0;
for (int i = 0; i < n; i++)
{
double p = 0.0;
if (ar[i] == 0)
{
ret += 1.0;
continue;
}
if (ar[i] == n - 1)
{
ret+= (n/2 + n%2) / (double)n;
continue;
}
for (int j = 0; j < n; j++)
{
for (int k = 0; k <= ar[i]; k+=2)
{
if (k > j)
break;
if (k > ar[i])
break;
var x = Combination(ar[i], k);
var y = Combination(n - 1 - ar[i], j - k);
var z = Combination(n - 1, j);
p += (x * y) / z;

}
}
ret += p / n;
}
Console.WriteLine(ret);
}
static double Combination(int n, int k)
{
double ret = 1;
double d = 1;
for (int i = 1; i <= k; i++)
{
ret *= (n + 1 - i);
d *= i;
}
return ret / d;
}

}

public class Scanner
{
string[] buffer = new string[0];
int position;

public char[] Separator { get; set; }
{
else
if (string.IsNullOrEmpty(separator))
separator = " ";
this.Separator = separator.ToCharArray();

}
public string Scan()
{
if (this.position < this.buffer.Length)
return this.buffer[this.position++];
this.position = 0;
return this.buffer[this.position++];
}

public string[] ScanToEndLine()
{
if (this.position >= this.buffer.Length)
var size = this.buffer.Length - this.position;
var ar = new string[size];
Array.Copy(this.buffer, position, ar, 0, size);
return ar;

}

public string ScanLine()
{
if (this.position >= this.buffer.Length)
else
{
var sb = new StringBuilder();
for (; this.position < buffer.Length; this.position++)
{
sb.Append(this.buffer[this.position]);
sb.Append(' ');
}
return sb.ToString();
}
}
public string[] ScanArray(int length)
{
var ar = new string[length];
for (int i = 0; i < length; i++)
{
ar[i] = this.Scan();
}
return ar;
}

public int Integer()
{
return int.Parse(this.Scan());
}
public long Long()
{
return long.Parse(this.Scan());
}
public double Double()
{
return double.Parse(this.Scan());
}

public int[] IntArray(int length)
{
var a = new int[length];
for (int i = 0; i < length; i++)
a[i] = this.Integer();
return a.ToArray();
}
public long[] LongArray(int length)
{
var a = new long[length];
for (int i = 0; i < length; i++)
a[i] = this.Long();
return a.ToArray();
}
public double[] DoubleArray(int length)
{
var a = new double[length];
for (int i = 0; i < length; i++)
a[i] = this.Double();
return a.ToArray();
}

}
static public partial class EnumerableEx
{
static public string AsString(this IEnumerable<char> source)
{
return new string(source.ToArray());
}
}
//*/```

#### Submission Info

Submission Time 2014-05-10 22:48:39+0900 C - コイン camypaper C# (Mono 2.10.8.1) 100 4673 Byte AC 274 ms 8716 KB

#### Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
sample_01.txt 152 ms 8704 KB
sample_02.txt 155 ms 8568 KB
sample_03.txt 152 ms 8700 KB