Submission #6518766


Source Code Expand

package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInput() ([]int, bool) {
	sc.Split(bufio.ScanWords)

	// read num of input.
	N := 0
	if sc.Scan() {
		n, err := strconv.Atoi(sc.Text())
		if err != nil {
			return nil, false
		}
		N = n
	}

	A := make([]int, N)
	for i := range A {
		if !sc.Scan() {
			return nil, false
		}
		a, err := strconv.Atoi(sc.Text())
		if err != nil {
			return nil, false
		}
		A[i] = a
	}
	return A, true
}

func main() {

	A, b := getInput()
	if !b {
		return
	}

	num := 0
	for {
		isAllEnv := true
		for i := range A {
			// 奇数
			if A[i]&0x00000001 == 1 {
				isAllEnv = false
				break
			}
			A[i] = A[i] >> 1
		}
		if !isAllEnv {
			break
		}
		num++
	}

	fmt.Println(num)
}

Submission Info

Submission Time
Task B - Shift only
User feketerigo
Language Go (1.6)
Score 200
Code Size 832 Byte
Status AC
Exec Time 1 ms
Memory 640 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 13
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All sample1.txt, sample2.txt, sample3.txt, 1.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
1.txt AC 1 ms 640 KB
2.txt AC 1 ms 640 KB
3.txt AC 1 ms 640 KB
4.txt AC 1 ms 640 KB
5.txt AC 1 ms 640 KB
6.txt AC 1 ms 640 KB
7.txt AC 1 ms 640 KB
sample1.txt AC 1 ms 640 KB
sample2.txt AC 1 ms 640 KB
sample3.txt AC 1 ms 640 KB