結果

問題 No.347 微分と積分
ユーザー YoshYosh
提出日時 2016-02-28 23:31:45
言語 Haskell
(9.8.2)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 714 bytes
コンパイル時間 2,033 ms
コンパイル使用メモリ 164,300 KB
実行使用メモリ 5,520 KB
最終ジャッジ日時 2023-10-24 18:56:29
合計ジャッジ時間 2,882 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,504 KB
testcase_01 AC 2 ms
5,484 KB
testcase_02 AC 2 ms
5,520 KB
testcase_03 AC 2 ms
5,492 KB
testcase_04 AC 2 ms
5,480 KB
testcase_05 AC 2 ms
5,468 KB
testcase_06 AC 2 ms
5,472 KB
testcase_07 AC 3 ms
5,496 KB
testcase_08 AC 2 ms
5,500 KB
testcase_09 AC 2 ms
5,488 KB
testcase_10 AC 3 ms
5,520 KB
testcase_11 AC 2 ms
5,488 KB
testcase_12 AC 3 ms
5,496 KB
testcase_13 AC 2 ms
5,464 KB
testcase_14 AC 2 ms
5,492 KB
testcase_15 AC 2 ms
5,492 KB
testcase_16 AC 2 ms
5,496 KB
testcase_17 AC 2 ms
5,512 KB
testcase_18 AC 3 ms
5,492 KB
testcase_19 AC 2 ms
5,488 KB
testcase_20 AC 2 ms
5,472 KB
testcase_21 AC 2 ms
5,516 KB
testcase_22 AC 2 ms
5,464 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

-- http://yukicoder.me/problems/836
-- No.347
import Control.Applicative
import Data.List

type Polyn = [(Double,Double)]

diff :: Polyn -> Polyn
diff = map (\(factor,pow) -> (pow*factor, pow-1))

-- intg :: Polyn -> Polyn
-- intg = map (\(factor,pow) -> let p' = pow + 1 in (factor/p', p'))

app :: Double -> Polyn ->  Double
app x = sum . map (\(f,p) -> f*(x**p))

intg :: Double -> Polyn -> Double
intg b = foldl' (
    \acc (f,p) -> acc + case p of (-1) -> f*log b
                                  _  ->  let p' = p+1 in (f/p' * b**p')
                ) 0

main = do
    _ <- getLine
    b <- readLn
    as <- zip (repeat 1) . map read . words <$> getLine
    print . app b . diff $ as
    print . intg b $ as
0