結果

問題 No.347 微分と積分
コンテスト
ユーザー tsuchinaga
提出日時 2019-03-28 11:45:07
言語 Go
(1.26.1)
コンパイル:
env GOCACHE=/tmp go build _filename_
実行:
./Main
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 499 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 14,634 ms
コンパイル使用メモリ 280,468 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-29 18:13:56
合計ジャッジ時間 16,128 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package main

import (
	"fmt"
	"math"
)

func main() {
	var n, x int
	_, _ = fmt.Scan(&n, &x)

	f := 0.0
	nums := make([]float64, n)
	for i := range nums {
		_, _ = fmt.Scan(&f)
		nums[i] = f
	}

	// 微分
	a := 0.0
	for _, n := range nums {
		a += n * math.Pow(float64(x), n-1)
	}
	fmt.Printf("%.5f\n", a)

	// 積分
	b := 0.0
	for _, n := range nums {
		if n == -1 {
			b += math.Log(math.Abs(float64(x)))
		} else {
			b += math.Pow(float64(x), n+1) / (n + 1)
		}
	}
	fmt.Printf("%.5f\n", b)
}
0