結果

問題 No.970 数列変換マシン
ユーザー neko_the_shadowneko_the_shadow
提出日時 2020-02-05 09:36:36
言語 Go
(1.22.1)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 1,264 bytes
コンパイル時間 13,473 ms
コンパイル使用メモリ 212,048 KB
実行使用メモリ 10,556 KB
最終ジャッジ日時 2023-10-22 02:54:25
合計ジャッジ時間 16,009 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,520 KB
testcase_01 AC 31 ms
10,556 KB
testcase_02 AC 33 ms
10,524 KB
testcase_03 AC 25 ms
10,084 KB
testcase_04 AC 25 ms
10,084 KB
testcase_05 AC 27 ms
10,144 KB
testcase_06 AC 17 ms
9,880 KB
testcase_07 AC 25 ms
10,084 KB
testcase_08 AC 24 ms
10,084 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

func exec(stdin *Stdin, stdout *Stdout) {
	n := stdin.ReadInt()
	y := []int{}
	for i := 0; i < n; i++ {
		y = append(y, stdin.ReadInt())
	}

	sum := 0
	for _, v := range y {
		sum += v * (n - 1)
	}
	sum /= n - 1

	ans := []string{}
	for _, v := range y {
		ans = append(ans, strconv.Itoa(sum-(v*(n-1))))
	}

	stdout.Println(strings.Join(ans, " "))
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}
0