結果

問題 No.2063 ±2^k operations (easy)
ユーザー scrappyscrappy
提出日時 2022-09-23 20:51:45
言語 Go
(1.22.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 11,685 ms
コンパイル使用メモリ 206,352 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-23 21:07:19
合計ジャッジ時間 12,823 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,504 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// No.2063 ±2^k operations (easy)
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0, 200000), 200000)
	sc.Scan()
	X := sc.Text()

	pos1 := strings.Index(X, "1")
	if pos1 < 0 {
		fmt.Println("No") // "0", n -> 0
	} else {
		count1 := strings.Count(X[pos1:], "1")
		if count1 < 2 {
			fmt.Println("No") // "10*", n -> 1 (-)
		} else if count1 == 2 {
			fmt.Println("Yes") // "10*10*", n -> 1 (-)(-)
		} else {
			pos0 := strings.Index(X[pos1:], "0")
			if pos0 < 0 {
				pos0 = len(X)
			}
			if pos0-pos1 == count1 {
				fmt.Println("Yes") // "11+0*", n -> 2 (+)(-)
			} else {
				fmt.Println("No") // "1+0+1.*", n -> 2 (+)(-)
			}
		}
	}
}
0