結果

問題 No.450 ベー君のシャトルラン
ユーザー 14番
提出日時 2016-12-19 13:45:44
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,893 bytes
コンパイル時間 2,750 ms
コンパイル使用メモリ 112,708 KB
実行使用メモリ 826,804 KB
最終ジャッジ日時 2024-12-14 08:54:39
合計ジャッジ時間 9,504 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 TLE * 1 MLE * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        decimal[] inpt = Reader.ReadLine().Split(' ').Select(a=>decimal.Parse(a)).ToArray();
        this.V1 = inpt[0];
        this.V2 = inpt[1];
        this.D = decimal.Parse(Reader.ReadLine());
        this.W = decimal.Parse(Reader.ReadLine());
        decimal ans = Math.Round(GetAns(0, D, true), 7);
        Console.WriteLine(ans);
    }

    private decimal GetAns(decimal v1Pos, decimal v2Pos, bool isLeft) {
        decimal diff = v2Pos - v1Pos;
        if(diff < 0.000000001m) {
            return diff;
        }
        decimal pos = 0;
        
        if(isLeft) {
            pos = diff / (V2 + W) * W;
            decimal nextV1 = pos / W * V1;
            decimal nextV2 = pos;
            return GetAns(nextV1, nextV2, !isLeft) + pos;
        } else {
            decimal mv = (diff / (V1 + W) * W);
            decimal nextV1 = v2Pos - mv;
            decimal nextV2 = v2Pos - (mv / W * V2);
            return GetAns(nextV1, nextV2, !isLeft) + mv;
        }
    }

    private decimal V1;
    private decimal V2;

    private decimal D;
    private decimal W;


    public class Reader {
        public static bool IsDebug = true;
        private static System.IO.StringReader SReader;
        private static string InitText = @"


90 568
5019
870




";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }

    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0