結果
| 問題 | No.246 質問と回答 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-07-13 11:20:11 |
| 言語 | Go (1.23.4) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 977 bytes |
| 記録 | |
| コンパイル時間 | 15,317 ms |
| コンパイル使用メモリ | 223,632 KB |
| 実行使用メモリ | 25,556 KB |
| 平均クエリ数 | 2.00 |
| 最終ジャッジ日時 | 2024-07-16 06:49:01 |
| 合計ジャッジ時間 | 18,365 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 30 |
ソースコード
package main
import (
"fmt"
)
import (
"bufio"
"os"
"strconv"
"bytes"
)
func main() {
screenBuffer := bytes.NewBuffer(nil)
screenWriter := bufio.NewWriterSize(screenBuffer, 8192)
A := 0
B := pow(10, 9) + 1
for B-A > 1 {
c := (A + B) / 2
fmt.Print("? ")
fmt.Println(c)
screenWriter.Flush()
ans := nextInt()
if ans == 1 {
A = c
}else {
B = c
}
}
fmt.Print("! ")
fmt.Println(A)
}
var s = bufio.NewScanner(os.Stdin)
func next() string {
s.Split(bufio.ScanWords)
s.Scan()
return s.Text()
}
func nextLine() string {
s.Split(bufio.ScanLines)
s.Scan()
return s.Text()
}
func nextInt() int {
i, e := strconv.Atoi(next())
if e != nil {
panic(e)
}
return i
}
func nextLong() int64 {
i, e := strconv.ParseInt(next(), 10, 64)
if e != nil {
panic(e)
}
return i
}
//aのb乗をします O(log b)
func pow(a int, b int) int {
total := 1
tmp := a
for b > 0 {
if b%2 == 1 {
total*=tmp
}
b/=2
tmp*=tmp
}
return total
}