結果

問題 No.598 オーバーフローファンタジー
コンテスト
ユーザー murosan
提出日時 2017-11-24 23:06:27
言語 Go
(1.26.1)
コンパイル:
env GOCACHE=/tmp go build _filename_
実行:
./Main
結果
AC  
実行時間 1,053 ms / 2,000 ms
コード長 464 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 10,939 ms
コンパイル使用メモリ 279,564 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-31 19:41:00
合計ジャッジ時間 13,189 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package main

import (
	"fmt"
)

func main() {
	var n, x, a, b int64
	fmt.Scan(&n, &x, &a, &b)
	max := pow(2, n)/2 - 1

	hp1 := x
	attack := 0
	for hp1 > 0 {
		hp1 -= a
		attack++
	}

	hp2 := x
	recovery := 0
	for hp2 <= max {
		hp2 += b
		recovery++
	}
	
	if attack < recovery {
		fmt.Println(attack)
	} else {
		fmt.Println(recovery)
	}
}

func pow(n, k int64) int64 {
	r := int64(1)
	for ; k > 0; k >>= 1 {
		if k&1 == 1 {
			r *= n
		}
		n *= n
	}
	return r
}
0