結果

問題 No.1869 Doubling?
ユーザー ID 21712
提出日時 2025-06-09 22:29:08
言語 Go
(1.23.4)
結果
WA  
実行時間 -
コード長 416 bytes
コンパイル時間 11,911 ms
コンパイル使用メモリ 246,904 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-06-09 22:29:24
合計ジャッジ時間 13,631 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import . "fmt"
import . "sort"

func main() {
	var n, m int
	Scan(&n,&m)
	
	x := Search(m+1, func(i int) bool {
		j := i
		c := 0
		for j > 1 {
			c++
			if j % 2 == 0 {
				j /= 2	
			} else {
				j = (j+1)/2
			}
		}
		return n - c <= 1
	})
	x = min(m, max(1, x))
	s, c := 0, 0
	for x > 1 {
		s += x
		c++
		if x % 2 == 0 {
			x /= 2
		} else {
			x = (x+1)/2
		}
	}
	ans := s + (n-c)
	Println(ans)
}
0