結果

問題 No.246 質問と回答
ユーザー nokonokonokonoko
提出日時 2015-07-18 15:06:23
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 3,064 bytes
コンパイル時間 3,326 ms
コンパイル使用メモリ 108,072 KB
実行使用メモリ 39,740 KB
平均クエリ数 66.30
最終ジャッジ日時 2023-09-23 20:00:48
合計ジャッジ時間 7,271 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
39,328 KB
testcase_01 AC 97 ms
37,556 KB
testcase_02 AC 98 ms
35,588 KB
testcase_03 AC 98 ms
37,264 KB
testcase_04 AC 97 ms
37,500 KB
testcase_05 AC 97 ms
37,800 KB
testcase_06 AC 98 ms
39,268 KB
testcase_07 AC 99 ms
37,520 KB
testcase_08 AC 98 ms
39,180 KB
testcase_09 AC 101 ms
37,660 KB
testcase_10 AC 101 ms
37,792 KB
testcase_11 AC 101 ms
37,236 KB
testcase_12 AC 100 ms
39,668 KB
testcase_13 AC 99 ms
37,408 KB
testcase_14 AC 99 ms
37,436 KB
testcase_15 AC 100 ms
37,828 KB
testcase_16 AC 100 ms
37,532 KB
testcase_17 AC 101 ms
37,104 KB
testcase_18 AC 98 ms
37,412 KB
testcase_19 AC 99 ms
35,356 KB
testcase_20 AC 100 ms
37,608 KB
testcase_21 AC 101 ms
37,648 KB
testcase_22 AC 102 ms
37,624 KB
testcase_23 AC 101 ms
35,412 KB
testcase_24 AC 102 ms
37,924 KB
testcase_25 AC 102 ms
37,588 KB
testcase_26 AC 103 ms
39,248 KB
testcase_27 AC 100 ms
37,216 KB
testcase_28 AC 102 ms
39,740 KB
testcase_29 AC 102 ms
37,204 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        long answer = 500000000;
        long nowRange = answer / 2;
        long qCount = 100;
        while (nowRange > 0)
        {
            LIB.IO.W("? " + answer.ToString());
            LIB.IO.WFLUSH();
            if (LIB.IO.R<int>() == 1)
            {
                answer += nowRange;
            }
            else
            {
                answer -= nowRange;
            }
            nowRange >>= 1;
            qCount--;
        }
        answer -= qCount / 2;
        while(true)
        {
            LIB.IO.W("? " + answer.ToString());
            LIB.IO.WFLUSH();
            if (LIB.IO.R<int>() == 1)
            {
                answer++;
            }
            else
            {
                answer--;
                break;
            }
        }
        LIB.IO.W("! " + answer.ToString());
        LIB.IO.WFLUSH();
    }
}

namespace LIB
{
    public class IO
    {
        private const int WMAX = 1000;
        private static string WSTRING = "";
        public static T R<T>()
        {
            return (T)(Convert.ChangeType(R(), typeof(T)));
        }
        public static T[] R<T>(char splitter = ' ')
        {
            return R().Split(splitter).Select(v => UTILITY.PARSE<T>(v)).ToArray();
        }
        public static T[] R<T>(int length)
        {

            T[] ret = new T[length];
            for (int i = 0; i < length; i++)
            {
                ret[i] = R<T>();
            }
            return ret;
        }
        public static T[][] R<T>(int length, char splitter = ' ')
        {
            T[][] ret = new T[length][];
            for (int i = 0; i < length; i++)
            {
                ret[i] = R<T>(splitter);
            }
            return ret;
        }
        private static string R()
        {
            return Console.ReadLine();
        }
        public static void W(object value, bool addLineFeed = true)
        {
            WSTRING += UTILITY.PARSE<string>(value);
            if (addLineFeed == true) { WSTRING += "\n"; }
            if (WSTRING.Count() >= WMAX) { WFLUSH(); }
        }
        public static void WFLUSH()
        {
            Console.Write(WSTRING);
            WSTRING = "";
        }
    }
    public class UTILITY
    {
        public static T PARSE<T>(object value)
        {
            return (T)(Convert.ChangeType(value, typeof(T)));
        }
    }
    public class MEMO<Key, Result>
    {
        private Dictionary<Key, Result> results;
        public MEMO()
        {
            results = new Dictionary<Key, Result>();
        }
        public Result EXEC(Key key, Func<Key, Result> func)
        {
            Result ret = default(Result);
            if (results.ContainsKey(key))
            {
                ret = results[key];
            }
            else
            {
                ret = func(key);
                results.Add(key, ret);
            }
            return ret;
        }
    }
}
0