結果

問題 No.253 ロウソクの長さ
ユーザー mban
提出日時 2017-04-28 10:13:20
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 1,218 bytes
コンパイル時間 2,160 ms
コンパイル使用メモリ 112,216 KB
実行使用メモリ 34,720 KB
平均クエリ数 23.89
最終ジャッジ日時 2024-07-17 00:54:56
合計ジャッジ時間 6,051 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

public class Program
{
    static public void Main(string[] args)
    {
        Console.WriteLine("? 64");
        string s = Console.ReadLine();
        int min = -1, max = -1;
        switch (s)
        {
            case "-1":
                max = 64;
                min = 10;
                break;
            case "1":
                max = (int)1e9 + 1;
                min = 65;
                break;
            case "0":
                Console.WriteLine("! 64");
                return;
        }

        for (int i = 1; ; i++)
        {
            int mid = (min + max) / 2;
            Console.WriteLine($"? {mid - i}");
            s = Console.ReadLine();
            switch (s)
            {
                case "-1":
                    max = mid - 1;

                    break;
                case "1":

                    min = mid + 1;
                    break;
                case "0":
                    Console.WriteLine($"! {mid}");
                    return;
            }
        }
    }
}

0