結果

問題 No.3680 セグメント釣り
コンテスト
ユーザー aketijyuuzou
提出日時 2026-09-05 14:38:02
言語 C#(csc)
(csc 3.9.0)
コンパイル:
csc -langversion:latest -unsafe -warn:0 -o+ /r:System.Numerics.dll _filename_ -out:a.exe
実行:
/usr/bin/mono a.exe
結果
WA  
実行時間 -
コード長 1,931 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,357 ms
コンパイル使用メモリ 109,440 KB
実行使用メモリ 45,312 KB
最終ジャッジ日時 2026-09-05 14:38:21
合計ジャッジ時間 16,572 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge7_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4 WA * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #
raw source code

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("1 0 4 1");
            WillReturn.Add("2 4 15 4");
            WillReturn.Add("0 0 1000000000000000000 1000000000000000000");
            //3
            //0
            //1000000000000000000
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static decimal[] GetSplitArr(string pStr)
    {
        return (pStr == "" ? new string[0] : pStr.Split(' ')).Select(pX => decimal.Parse(pX)).ToArray();
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        decimal[] wkArr = { };
        Action<string> SplitAct = (pStr) => wkArr = GetSplitArr(pStr);

        foreach (string EachStr in InputList.Skip(1)) {
            SplitAct(EachStr);
            decimal SX = wkArr[0];
            decimal SY = wkArr[1];
            decimal TX = wkArr[2];
            decimal TY = wkArr[3];
            decimal Answer = Solve(SX, SY, TX, TY);
            Console.WriteLine(Answer);
        }
    }

    static decimal Solve(decimal pSX, decimal pSY, decimal pTX, decimal pTY)
    {
        decimal Answer = 0;

        // Y座標の移動コスト
        Answer += Math.Abs(pSY - pTY);

        decimal AnswerY = Math.Max(pSY, pTY);
        decimal Beki2 = 1;
        for (long I = 1; I <= AnswerY; I++) {
            Beki2 *= 2;
            if (Beki2 > long.MaxValue) break;
        }

        decimal Div1 = Math.Truncate(pSX / Beki2);
        decimal Div2 = Math.Truncate(pTX / Beki2);
        Answer += Math.Abs(Div1 - Div2);
        return Answer;
    }
}
0