結果

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

ソースコード

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+1
		c := 0
		for j > 1 {
			c++
			if j % 2 == 0 {
				j /= 2	
			} else {
				j = (j+1)/2
			}
		}
		return n - c < 0
	})
	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