結果

問題 No.2103 ±1s Game
ユーザー kakel-san
提出日時 2022-10-21 22:27:04
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 29 ms / 1,000 ms
コード長 899 bytes
コンパイル時間 890 ms
コンパイル使用メモリ 109,612 KB
実行使用メモリ 27,388 KB
最終ジャッジ日時 2024-07-01 06:58:42
合計ジャッジ時間 3,019 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        WriteLine(Game(c[0], c[1], c[2], c[3]) ? "Alice" : "Bob");
    }
    static bool Game(long x, long y, long k, long p)
    {
        var d = x - y;
        if (k % 2 == 1)
        {
            if (d >= k)
            {
                return p == 1;
            }
            if (d <= -k)
            {
                return p == -1;
            }
            return d % 2 == 0;
        }
        else
        {
            if (Math.Abs(d) >= k)
            {
                return p == 1;
            }
            return d % 2 != 0;
        }
    }
}
0