結果
問題 | No.538 N.G.S. |
ユーザー | くれちー |
提出日時 | 2017-08-14 23:30:20 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 8,538 bytes |
コンパイル時間 | 1,272 ms |
コンパイル使用メモリ | 122,400 KB |
実行使用メモリ | 29,512 KB |
最終ジャッジ日時 | 2024-10-13 10:03:00 |
合計ジャッジ時間 | 3,892 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 30 ms
27,452 KB |
testcase_02 | AC | 30 ms
27,488 KB |
testcase_03 | AC | 32 ms
25,412 KB |
testcase_04 | WA | - |
testcase_05 | AC | 29 ms
23,344 KB |
testcase_06 | AC | 30 ms
25,452 KB |
testcase_07 | WA | - |
testcase_08 | AC | 30 ms
25,460 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 32 ms
25,436 KB |
testcase_15 | WA | - |
testcase_16 | AC | 31 ms
25,552 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 32 ms
25,556 KB |
testcase_20 | WA | - |
testcase_21 | AC | 30 ms
27,592 KB |
testcase_22 | WA | - |
testcase_23 | AC | 32 ms
25,456 KB |
testcase_24 | WA | - |
testcase_25 | AC | 31 ms
25,652 KB |
testcase_26 | WA | - |
testcase_27 | AC | 30 ms
23,216 KB |
testcase_28 | AC | 31 ms
27,584 KB |
testcase_29 | WA | - |
testcase_30 | AC | 30 ms
25,328 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 30 ms
25,328 KB |
testcase_34 | WA | - |
testcase_35 | AC | 30 ms
25,712 KB |
testcase_36 | AC | 29 ms
25,576 KB |
testcase_37 | AC | 30 ms
23,220 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | AC | 31 ms
25,644 KB |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | AC | 31 ms
27,344 KB |
testcase_49 | AC | 29 ms
25,540 KB |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | AC | 31 ms
25,448 KB |
testcase_53 | AC | 31 ms
25,452 KB |
testcase_54 | WA | - |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Numerics; using System.Text; using static System.Console; using static System.Convert; using static System.Math; using static Extentions; class IO { int idx; string[] input = In.ReadToEnd().Split(new[] { " ", "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries); T Get<T>(Func<string, T> parser) => parser(input[idx++]); public string S => Get(s => s); public char C => Get(char.Parse); public int I => Get(int.Parse); public long L => Get(long.Parse); public double F => Get(double.Parse); public decimal D => Get(decimal.Parse); public BigInteger B => Get(BigInteger.Parse); T[] Gets<T>(int n, Func<string, T> parser) => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray(); public string[] Ss(int n) => Gets(n, s => s); public char[] Cs(int n) => Gets(n, char.Parse); public int[] Is(int n) => Gets(n, int.Parse); public long[] Ls(int n) => Gets(n, long.Parse); public double[] Fs(int n) => Gets(n, double.Parse); public decimal[] Ds(int n) => Gets(n, decimal.Parse); public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse); public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs)); public void Write(params object[] xs) => WriteLine(string.Join(" ", xs)); } interface IInteger<T> { T MinusOne { get; } T One { get; } T Zero { get; } T Add(T left, T right); int Compare(T left, T right); T Divide(T dividend, T divisor); T Multiply(T left, T right); T Negate(T value); T Remainder(T dividend, T divisor); T Subtract(T left, T right); } static class Integer<T> { static IInteger<int> i = new IntOperations(); static IInteger<long> l = new LongOperations(); static IInteger<BigInteger> bi = new BigIntegerOperations(); public static IInteger<T> Default { get { if (typeof(T) == typeof(int)) return (IInteger<T>)i; else if (typeof(T) == typeof(long)) return (IInteger<T>)l; else if (typeof(T) == typeof(BigInteger)) return (IInteger<T>)bi; else throw new NotSupportedException(); } } } class IntOperations : IInteger<int> { public int MinusOne => -1; public int One => 1; public int Zero => 0; public int Add(int left, int right) => checked(left + right); public int Compare(int left, int right) => left.CompareTo(right); public int Divide(int dividend, int divisor) => dividend / divisor; public int Multiply(int left, int right) => checked(left * right); public int Negate(int value) => checked(-value); public int Remainder(int dividend, int divisor) => dividend % divisor; public int Subtract(int left, int right) => checked(left - right); } class LongOperations : IInteger<long> { public long MinusOne => -1; public long One => 1; public long Zero => 0; public long Add(long left, long right) => checked(left + right); public int Compare(long left, long right) => left.CompareTo(right); public long Divide(long dividend, long divisor) => dividend / divisor; public long Multiply(long left, long right) => checked(left * right); public long Negate(long value) => checked(-value); public long Remainder(long dividend, long divisor) => dividend % divisor; public long Subtract(long left, long right) => checked(left - right); } class BigIntegerOperations : IInteger<BigInteger> { public BigInteger MinusOne => BigInteger.MinusOne; public BigInteger One => BigInteger.One; public BigInteger Zero => BigInteger.Zero; public BigInteger Add(BigInteger left, BigInteger right) => BigInteger.Add(left, right); public int Compare(BigInteger left, BigInteger right) => BigInteger.Compare(left, right); public BigInteger Divide(BigInteger dividend, BigInteger divisor) => BigInteger.Divide(dividend, divisor); public BigInteger Multiply(BigInteger left, BigInteger right) => BigInteger.Multiply(left, right); public BigInteger Negate(BigInteger value) => BigInteger.Negate(value); public BigInteger Remainder(BigInteger dividend, BigInteger divisor) => BigInteger.Remainder(dividend, divisor); public BigInteger Subtract(BigInteger left, BigInteger right) => BigInteger.Subtract(left, right); } struct Rational<T> : IComparable<Rational<T>>, IEquatable<Rational<T>> { T numer; T denom; public T Numer { get { this.Reduce(); return numer; } } public T Denom { get { this.Reduce(); return denom; } } IInteger<T> i; public int Sign => i.Compare(numer, i.Zero) * i.Compare(denom, i.Zero); public Rational(T numer, T denom) { this.numer = numer; this.denom = denom; i = Integer<T>.Default; } void Reduce() { if (i.Compare(numer, i.Zero) == 0) { denom = i.One; return; } var d = Gcd(numer, denom, i); var neg = i.Compare(denom, i.Zero) < 0; numer = i.Divide(neg ? i.Negate(numer) : numer, d); denom = i.Divide(neg ? i.Negate(denom) : denom, d); } public Rational<T> Invert() => new Rational<T>(denom, numer); public static Rational<T> operator -(Rational<T> r) => new Rational<T>(r.i.Negate(r.numer), r.denom); public static Rational<T> operator +(Rational<T> left, Rational<T> right) { var i = left.i; left.Reduce(); right.Reduce(); var d = Lcm(left.denom, right.denom, i); var n = i.Add(i.Divide(i.Multiply(left.numer, d), left.denom), i.Divide(i.Multiply(right.numer, d), right.denom)); return new Rational<T>(n, d); } public static Rational<T> operator *(Rational<T> left, Rational<T> right) { var i = left.i; left.Reduce(); right.Reduce(); var n = i.Multiply(left.numer, right.numer); var d = i.Multiply(left.denom, right.denom); return new Rational<T>(n, d); } public static Rational<T> operator -(Rational<T> left, Rational<T> right) => left + -right; public static Rational<T> operator /(Rational<T> left, Rational<T> right) => left * right.Invert(); public static bool operator ==(Rational<T> left, Rational<T> right) => left.Equals(right); public static bool operator !=(Rational<T> left, Rational<T> right) => !left.Equals(right); public static bool operator <(Rational<T> left, Rational<T> right) => left.CompareTo(right) < 0; public static bool operator >(Rational<T> left, Rational<T> right) => left.CompareTo(right) > 0; public static bool operator <=(Rational<T> left, Rational<T> right) => left.CompareTo(right) <= 0; public static bool operator >=(Rational<T> left, Rational<T> right) => left.CompareTo(right) >= 0; public static implicit operator Rational<T>(T x) => new Rational<T>(x, Integer<T>.Default.One); public int CompareTo(Rational<T> other) => (this - other).Sign; public bool Equals(Rational<T> other) { var r = this / other; return r.i.Compare(r.numer, r.denom) == 0; } public override bool Equals(object obj) { if (!(obj is Rational<T>)) return false; var r = (Rational<T>)obj / this; return r.i.Compare(r.numer, r.denom) == 0; } public override int GetHashCode() => this.Numer.GetHashCode() ^ this.Denom.GetHashCode(); public override string ToString() => $"{this.Numer}/{this.Denom}"; } static partial class Extentions { public static T Gcd<T>(T x, T y, IInteger<T> integer) { T r; while (integer.Compare((r = integer.Remainder(x, y)), integer.Zero) != 0) { x = y; y = r; } return y; } public static T Lcm<T>(T x, T y, IInteger<T> integer) => integer.Multiply(integer.Divide(x, Gcd(x, y, integer)), y); } static class Program { public static void Main() { var sw = new StreamWriter(OpenStandardOutput()) { NewLine = "\n" }; #if DEBUG sw.AutoFlush = true; #else sw.AutoFlush = false; #endif SetOut(sw); Solve(new IO()); Out.Flush(); } static void Solve(IO io) { var b = io.Ls(3); var d = new Rational<long>(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).Numer); } }