結果

問題 No.3072 Sum of sqrt(x)
ユーザー Lisp_CoderLisp_Coder
提出日時 2022-12-24 17:45:03
言語 Go
(1.22.1)
結果
TLE  
実行時間 -
コード長 568 bytes
コンパイル時間 14,867 ms
コンパイル使用メモリ 221,660 KB
実行使用メモリ 32,956 KB
最終ジャッジ日時 2024-04-29 04:56:33
合計ジャッジ時間 27,317 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

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

func main() {
	// use bufio for fast I/O
	scanner := bufio.NewScanner(os.Stdin)

	// read the length of the sequence
	var n int
	scanner.Scan()
	fmt.Sscan(scanner.Text(), &n)

	// read the sequence
	var x []int
	for i := 0; i < n; i++ {
		var xi int
		scanner.Scan()
		fmt.Sscan(scanner.Text(), &xi)
		x = append(x, xi)
	}

	// compute the sum of sqrt(xi) for each k
	for k := 0; k < n; k++ {
		var sum float64
		for i := 0; i <= k; i++ {
			sum += math.Sqrt(float64(x[i]))
		}
		fmt.Printf("%.16f\n", sum)
	}
}
0