結果

問題 No.2063 ±2^k operations (easy)
ユーザー Hima
提出日時 2022-10-09 17:24:48
言語 Go
(1.23.4)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 733 bytes
コンパイル時間 12,983 ms
コンパイル使用メモリ 238,008 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-23 16:29:06
合計ジャッジ時間 13,750 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	n := nextString()
	ans := solve(n)
	PrintString(ans)
}

func solve(n string) string {
	//ビットが立っている数
	var cnt int
	for _, v := range n {
		if v == '1' {
			cnt++
		}
	}
	if cnt == 2 {
		return "Yes"
	} else if cnt <= 1 {
		return "No"
	}
	for i := 0; i < len(n)-1; i++ {
		if n[i] == '0' && n[i+1] == '1' {
			return "No"
		}
	}
	return "Yes"
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func PrintString(x string) {
	defer out.Flush()
	fmt.Fprintln(out, x)
}
0