Submission #222959


Source Code Expand

Copy
using System;
using System.Collections.Generic;
using System.Linq;
class Problem
{
    static void Main()
    {
        System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");
#if DEBUG
        var stream = new System.IO.StreamWriter("../../debug.txt");
        System.Diagnostics.Debug.AutoFlush = true;
        System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(stream));
#endif
        var problem = new Problem();
        problem.Solve();
#if DEBUG
        Console.ReadKey(true);
#endif
    }
    void Solve()
    {
        var sc = new Scanner();
        var n = sc.Integer();
        var C = sc.IntArray(n);
        var h = new int[n];
        var E = new double[n];
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if (i == j)
                    continue;
                if (C[j] % C[i] == 0)
                    h[j]++;
            }
        }
        for (int i = 0; i < n; i++)
        {
            var v = C[i];
            var m = h[i];
            var count = 0;
            for (int k = 0; k <= m; k++)
            {
                if (k % 2 == 0)
                    count += 1;
            }
            var d = (double)count;
            E[i] += d / (m + 1);
        }
        var ans = E.Sum();
        for (int i = 0; i < n; i++)
        {
            System.Diagnostics.Debug.WriteLine("E({0}):{1}",C[i],E[i]);
        }
        System.Diagnostics.Debug.WriteLine("sum:{0}",ans);
        Console.WriteLine(ans);
    }

}

public class Scanner
{
    readonly System.IO.TextReader reader;
    string[] buffer = new string[0];
    int position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null)
    {
        if (reader == null)
            this.reader = Console.In;
        else
            this.reader = reader;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        this.Separator = separator.ToCharArray();

    }
    public string Scan()
    {
        if (this.position < this.buffer.Length)
            return this.buffer[this.position++];
        this.buffer = this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);
        this.position = 0;
        return this.buffer[this.position++];
    }

    public string[] ScanToEndLine()
    {
        if (this.position >= this.buffer.Length)
            return this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);
        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)
            return this.reader.ReadLine();
        else
        {
            var sb = new System.Text.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;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Double();
        return a;
    }

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

//*/

Submission Info

Submission Time
Task C - コイン
User camypaper
Language C# (Mono 2.10.8.1)
Score 100
Code Size 4507 Byte
Status
Exec Time 165 ms
Memory 8816 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 99 / 99 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt
Subtask2 1 / 1 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt, subtask2_16.txt, subtask2_17.txt, subtask2_18.txt, subtask2_19.txt, subtask2_20.txt
Case Name Status Exec Time Memory
sample_01.txt 151 ms 8684 KB
sample_02.txt 152 ms 8684 KB
sample_03.txt 152 ms 8720 KB
subtask1_01.txt 151 ms 8688 KB
subtask1_02.txt 149 ms 8736 KB
subtask1_03.txt 151 ms 8628 KB
subtask1_04.txt 150 ms 8688 KB
subtask1_05.txt 154 ms 8732 KB
subtask1_06.txt 156 ms 8688 KB
subtask1_07.txt 151 ms 8640 KB
subtask1_08.txt 152 ms 8644 KB
subtask1_09.txt 150 ms 8636 KB
subtask1_10.txt 153 ms 8664 KB
subtask1_11.txt 151 ms 8708 KB
subtask1_12.txt 151 ms 8648 KB
subtask1_13.txt 150 ms 8640 KB
subtask1_14.txt 152 ms 8756 KB
subtask1_15.txt 151 ms 8692 KB
subtask1_16.txt 149 ms 8640 KB
subtask1_17.txt 151 ms 8712 KB
subtask1_18.txt 152 ms 8640 KB
subtask1_19.txt 150 ms 8668 KB
subtask1_20.txt 151 ms 8692 KB
subtask2_01.txt 152 ms 8652 KB
subtask2_02.txt 152 ms 8704 KB
subtask2_03.txt 153 ms 8704 KB
subtask2_04.txt 151 ms 8748 KB
subtask2_05.txt 153 ms 8672 KB
subtask2_06.txt 162 ms 8640 KB
subtask2_07.txt 151 ms 8704 KB
subtask2_08.txt 152 ms 8816 KB
subtask2_09.txt 152 ms 8636 KB
subtask2_10.txt 153 ms 8708 KB
subtask2_11.txt 149 ms 8640 KB
subtask2_12.txt 151 ms 8708 KB
subtask2_13.txt 152 ms 8664 KB
subtask2_14.txt 151 ms 8696 KB
subtask2_15.txt 155 ms 8708 KB
subtask2_16.txt 152 ms 8724 KB
subtask2_17.txt 159 ms 8700 KB
subtask2_18.txt 156 ms 8804 KB
subtask2_19.txt 158 ms 8636 KB
subtask2_20.txt 165 ms 8672 KB