func main() {
	nCases := jam.GetInt()
	for i := 0; i < nCases; i++ {
		nDim := jam.GetInt()
		// Populate v1
		v1 := make([]int, nDim)
		for i := 0; i < nDim; i++ {
			v1[i] = jam.GetInt()
		}
		// Populate v2
		v2 := make([]int, nDim)
		for i := 0; i < nDim; i++ {
			v2[i] = jam.GetInt()
		}
		v1 = jam.QuicksortInts(v1, true)
		v2 = jam.QuicksortInts(v2, false)
		fmt.Printf("Case #%d: %v\n", i+1, scalarProduct(v1, v2))
	}
}
示例#2
0
func main() {
	nCases := jam.GetInt()
	for i := 0; i < nCases; i++ {
		nFlavors := jam.GetInt()
		nCustomers := jam.GetInt()
		// For each customer, some number of "X Y" pairs, where X is
		// the flavor and Y is 1 for malted, 0 for unmalted
		likes := make([][][2]int, nCustomers)
		var T int // Number of pairs "X Y"
		for i := 0; i < nCustomers; i++ {
			T = jam.GetInt()
			likes[i] = jam.GetPairs(T)
		}

		output := "IMPOSSIBLE"
		toPrep, err := calculateBatches(nFlavors, likes)
		if err == nil {
			output = jam.FmtInts(toPrep)
		}
		fmt.Printf("Case #%d: %v\n", i+1, output)
	}
}
func main() {
	nCases := jam.GetInt()
	r := bufio.NewReader(os.Stdin)
	for i := 0; i < nCases; i++ {
		line, _ := r.ReadString('\n')
		words := strings.Split(line[:len(line)-1], " ")
		var reversed []string
		for _, word := range words {
			reversed = append([]string{word}, reversed...)
		}
		fmt.Printf("Case #%d: %v\n", i+1, strings.Join(reversed, " "))
	}
}
示例#4
0
func main() {
	nCases := jam.GetInt()
	r := bufio.NewReader(os.Stdin)
	for i := 0; i < nCases; i++ {
		var sequence string
		var c byte
		var err error
		for {
			c, err = r.ReadByte()
			if c == '\n' || err != nil {
				break
			}
			miniSeq := char2seq[c]
			if len(sequence) > 0 && sequence[len(sequence)-1] == miniSeq[0] {
				sequence += " "
			}
			sequence += miniSeq
		}
		fmt.Printf("Case #%d: %v\n", i+1, sequence)
	}
}