結果
問題 | No.538 N.G.S. |
ユーザー | くれちー |
提出日時 | 2017-07-03 23:14:00 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 5,397 bytes |
コンパイル時間 | 2,611 ms |
コンパイル使用メモリ | 109,824 KB |
実行使用メモリ | 24,192 KB |
最終ジャッジ日時 | 2024-10-05 12:52:22 |
合計ジャッジ時間 | 4,606 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
24,192 KB |
testcase_01 | AC | 28 ms
19,328 KB |
testcase_02 | AC | 27 ms
19,072 KB |
testcase_03 | AC | 29 ms
18,944 KB |
testcase_04 | TLE | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
testcase_52 | -- | - |
testcase_53 | -- | - |
testcase_54 | -- | - |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
#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 struct Rational { int numerator; int denominator; public int Numerator { get { this.Reduce(); return numerator; } set { numerator = value; } } public int Denominator { get { this.Reduce(); return denominator; } set { if (value == 0) throw new DivideByZeroException(); denominator = value; } } public Rational(int numerator, int 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 left, Rational right) { long n, d; var cnt = 0; do { n = (long)right.denominator * left.numerator + (long)left.denominator * right.numerator; d = (long)left.denominator * right.denominator; if (n < int.MinValue || n > int.MaxValue || d < int.MinValue || d > int.MaxValue) { left.Reduce(); right.Reduce(); cnt++; } if (cnt >= 2) throw new OverflowException(); } while (cnt > 0); return new Rational((int)n, (int)d); } public static Rational operator -(Rational left, Rational right) => left + -right; public static Rational operator *(Rational left, Rational right) { long n, d; var cnt = 0; do { n = (long)left.numerator * right.numerator; d = (long)left.denominator * right.denominator; if (n < int.MinValue || n > int.MaxValue || d < int.MinValue || d > int.MaxValue) { left.Reduce(); right.Reduce(); cnt++; } if (cnt >= 2) throw new OverflowException(); } while (cnt > 0); return new Rational((int)n, (int)d); } public static Rational operator /(Rational left, Rational right) => left * right.Invert(); public static Rational operator -(Rational r) => new Rational(-r.numerator, r.denominator); 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(int 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 ^ denominator; } } static class Program { static void Main() { Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); Solve(new IO()); Console.Out.Flush(); } static void Solve(IO io) { io.R(); var b = io.Is; 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); } }