結果

問題 No.538 N.G.S.
ユーザー くれちーくれちー
提出日時 2017-07-04 01:51:53
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 4,845 bytes
コンパイル時間 1,160 ms
コンパイル使用メモリ 114,400 KB
実行使用メモリ 25,420 KB
最終ジャッジ日時 2023-10-25 04:44:42
合計ジャッジ時間 4,435 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
25,412 KB
testcase_01 AC 34 ms
25,412 KB
testcase_02 AC 34 ms
25,420 KB
testcase_03 AC 34 ms
25,412 KB
testcase_04 AC 34 ms
25,412 KB
testcase_05 AC 34 ms
25,420 KB
testcase_06 AC 34 ms
25,412 KB
testcase_07 AC 34 ms
25,412 KB
testcase_08 AC 34 ms
25,412 KB
testcase_09 AC 34 ms
25,412 KB
testcase_10 AC 33 ms
25,412 KB
testcase_11 AC 34 ms
25,416 KB
testcase_12 AC 34 ms
25,412 KB
testcase_13 AC 34 ms
25,412 KB
testcase_14 AC 34 ms
25,416 KB
testcase_15 AC 33 ms
25,412 KB
testcase_16 AC 34 ms
25,416 KB
testcase_17 AC 35 ms
25,412 KB
testcase_18 AC 34 ms
25,412 KB
testcase_19 AC 35 ms
25,416 KB
testcase_20 AC 34 ms
25,412 KB
testcase_21 AC 34 ms
25,416 KB
testcase_22 AC 35 ms
25,412 KB
testcase_23 AC 36 ms
25,416 KB
testcase_24 AC 34 ms
25,412 KB
testcase_25 AC 35 ms
25,416 KB
testcase_26 AC 34 ms
25,412 KB
testcase_27 AC 34 ms
25,416 KB
testcase_28 AC 34 ms
25,412 KB
testcase_29 AC 35 ms
25,416 KB
testcase_30 AC 34 ms
25,416 KB
testcase_31 AC 36 ms
25,412 KB
testcase_32 AC 36 ms
25,416 KB
testcase_33 AC 34 ms
25,412 KB
testcase_34 AC 34 ms
25,412 KB
testcase_35 AC 35 ms
25,416 KB
testcase_36 AC 35 ms
25,412 KB
testcase_37 AC 34 ms
25,420 KB
testcase_38 AC 34 ms
25,420 KB
testcase_39 AC 34 ms
25,412 KB
testcase_40 AC 35 ms
25,412 KB
testcase_41 AC 34 ms
25,416 KB
testcase_42 AC 33 ms
25,412 KB
testcase_43 AC 34 ms
25,416 KB
testcase_44 AC 34 ms
25,416 KB
testcase_45 AC 34 ms
25,412 KB
testcase_46 AC 34 ms
25,412 KB
testcase_47 AC 34 ms
25,412 KB
testcase_48 AC 34 ms
25,412 KB
testcase_49 AC 34 ms
25,412 KB
testcase_50 AC 35 ms
25,412 KB
testcase_51 AC 34 ms
25,412 KB
testcase_52 AC 34 ms
25,416 KB
testcase_53 AC 34 ms
25,416 KB
testcase_54 AC 34 ms
25,416 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

#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 long Gcd(long x, long y)
    {
        long r;
        while ((r = x % y) != 0) { x = y; y = r; }
        return y;
    }

    public struct Rational
    {
        long numerator;
        long denominator;

        public long Numerator
        {
            get { this.Reduce(); return numerator; }
            set { numerator = value; }
        }
        public long Denominator
        {
            get { this.Reduce(); return denominator; }
            set { if (value == 0) throw new DivideByZeroException(); denominator = value; }
        }

        public Rational(long numerator, long denominator)
        {
            this.numerator = numerator;
            this.denominator = denominator;
        }

        void Reduce()
        {
            if (numerator == 0) { denominator = 1; return; }
            var d = Gcd(numerator, denominator);
            numerator /= d; denominator /= d;
            if (denominator < 0) { numerator *= -1; denominator *= -1; }
        }

        public Rational Invert() => new Rational(denominator, numerator);

        public static Rational operator -(Rational r) => new Rational(-r.numerator, r.denominator);

        public static Rational operator +(Rational left, Rational right)
        {
            left.Reduce(); right.Reduce();
            var n = checked(right.denominator * left.numerator + left.denominator * right.numerator);
            var d = checked(left.denominator * right.denominator);
            return new Rational(n, d);
        }

        public static Rational operator -(Rational left, Rational right) => left + -right;

        public static Rational operator *(Rational left, Rational right)
        {
            left.Reduce(); right.Reduce();
            var n = checked(left.numerator * right.numerator);
            var d = checked(left.denominator * right.denominator);
            return new Rational(n, d);
        }

        public static Rational operator /(Rational left, Rational right) => left * right.Invert();

        public static bool operator ==(Rational left, Rational right)
        {
            var r = left / right;
            return r.numerator == r.denominator;
        }

        public static bool operator !=(Rational left, Rational right)
        {
            var r = left / right;
            return r.numerator != r.denominator;
        }

        public static implicit operator Rational(long x) => new Rational(x, 1);

        public override bool Equals(object obj)
        {
            if (!(obj is Rational)) return false;
            var r = (Rational)obj / this;
            return r.numerator == r.denominator;
        }

        public override int GetHashCode() => numerator.GetHashCode() ^ denominator.GetHashCode();
    }
}

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

    public static void Solve(IO io)
    {
        io.R();
        var b = io.Ls;

        var d = new Rational(b[0] * b[2] - b[1] * b[1], b[0] - b[1]);
        var r = b[0] != 0 ? -(d - b[1]) / b[0] : -(d - b[2]) / b[1];

        io.Write((r * b[2] + d).Numerator);
    }
}
0