結果
| 問題 | No.246 質問と回答 |
| コンテスト | |
| ユーザー |
14番
|
| 提出日時 | 2016-05-14 23:42:52 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 97 ms / 2,000 ms |
| コード長 | 1,028 bytes |
| 記録 | |
| コンパイル時間 | 2,060 ms |
| コンパイル使用メモリ | 111,840 KB |
| 実行使用メモリ | 42,652 KB |
| 平均クエリ数 | 32.23 |
| 最終ジャッジ日時 | 2024-07-16 20:03:39 |
| 合計ジャッジ時間 | 6,003 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
public void Proc()
{
long ans = this.GetAns(1, 1000000000);
Console.WriteLine("! " + ans);
}
private long GetAns(long min, long max)
{
long mid = (min + max) / 2;
Console.WriteLine("? " + mid);
bool isBigger = Console.ReadLine().Equals("1");
if (isBigger && max - mid <= 1)
{
Console.WriteLine("? " + max);
isBigger = Console.ReadLine().Equals("1");
if (isBigger)
{
return max;
}
else
{
return mid;
}
}
if (isBigger)
{
return this.GetAns(mid, max);
}
else
{
return this.GetAns(min, mid);
}
}
static void Main(string[] args)
{
Program prg = new Program();
prg.Proc();
}
}
14番