結果

問題 No.2216 Pa1indr0me
ユーザー Hima
提出日時 2023-03-02 20:05:51
言語 Go
(1.23.4)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 759 bytes
コンパイル時間 12,233 ms
コンパイル使用メモリ 237,324 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-17 13:43:37
合計ジャッジ時間 12,265 ms
ジャッジサーバーID
(参考情報)
judge6 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

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

func main() {
	//bufサイズ以上の文字列入力が必要な場合は拡張すること
	buf := make([]byte, 9*1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	t := nextInt()
	var ans []int
	for i := 0; i < t; i++ {
		n := nextInt()
		ans = append(ans, solve(n))
	}
	PrintVertically(ans)
}

func solve(n int) int {
	return n * (n + 1)
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}

func PrintInt(x int) {
	defer out.Flush()
	fmt.Fprintln(out, x)
}

func PrintVertically(x []int) {
	defer out.Flush()
	for _, v := range x {
		fmt.Fprintln(out, v)
	}
}
0