結果

問題 No.546 オンリー・ワン
ユーザー くれちーくれちー
提出日時 2017-07-15 00:19:40
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,688 bytes
コンパイル時間 879 ms
コンパイル使用メモリ 112,180 KB
実行使用メモリ 27,700 KB
最終ジャッジ日時 2024-04-16 20:54:08
合計ジャッジ時間 1,729 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
19,328 KB
testcase_01 WA -
testcase_02 AC 29 ms
19,072 KB
testcase_03 WA -
testcase_04 AC 29 ms
19,200 KB
testcase_05 AC 30 ms
19,328 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

#pragma warning disable IDE1006
#pragma warning disable IDE0011
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] line;

    public void R(params char[] sep) { line = Console.ReadLine().Split(sep); idx = 0; }
    public string S => line[idx++];
    public string[] Ss => line.Skip(idx++).ToArray();
    public char C => char.Parse(line[idx++]);
    public char[] Cs => line.Skip(idx++).Select(char.Parse).ToArray();
    public int I => int.Parse(line[idx++]);
    public int[] Is => line.Skip(idx++).Select(int.Parse).ToArray();
    public long L => long.Parse(line[idx++]);
    public long[] Ls => line.Skip(idx++).Select(long.Parse).ToArray();
    public double F => double.Parse(line[idx++]);
    public double[] Fs => line.Skip(idx++).Select(double.Parse).ToArray();
    public decimal D => decimal.Parse(line[idx++]);
    public decimal[] Ds => line.Skip(idx++).Select(decimal.Parse).ToArray();
    public BigInteger B => BigInteger.Parse(line[idx++]);
    public BigInteger[] Bs => line.Skip(idx++).Select(BigInteger.Parse).ToArray();

    public void Write<T>(params T[] xs)
    {
        Console.Write(xs.First());
        foreach (var x in xs.Skip(1)) Console.Write(" " + x);
        Console.WriteLine();
    }
    public void Write(params object[] xs)
    {
        Console.Write(xs.First());
        foreach (var x in xs.Skip(1)) Console.Write(" " + x);
        Console.WriteLine();
    }
}

static class Extentions
{
    public static int Gcd(int x, int y)
    {
        int r;
        while ((r = x % y) != 0) { x = y; y = r; }
        return y;
    }

    public static int Lcm(int x, int y) => x * y / Gcd(x, y);
}

static class Program
{
    public static void Main()
    {
#if !DEBUG
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
#endif
        Solve(new IO());
        Console.Out.Flush();
    }

    public static void Solve(IO io)
    {
        io.R();
        var n = io.I;
        var l = io.I;
        var h = io.I;
        io.R();
        var c = io.Is;

        var t = new int[n];
        for (var i = 0; i < n; i++)
        {
            t[i] = h / c[i] - (l - 1) / c[i];
        }

        var s = new int[n];
        for (var i = 0; i < n; i++)
        {
            s[i] = t[i];
            for (var j = 0; j < n; j++)
            {
                if (j == i) continue;
                var d = Lcm(c[i], c[j]);
                s[i] -= h / d - (l - 1) / d;
            }
        }

        io.Write(s.Sum());
    }
}
0