結果

問題 No.347 微分と積分
ユーザー はむ吉🐹
提出日時 2016-02-26 23:00:06
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 5,000 ms
コード長 655 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-09-22 22:38:37
合計ジャッジ時間 1,718 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import math


EPS = 10 ** (-12)


def differentiate(exps, b):
    answer = 0
    for a in exps:
        if abs(a) > EPS:
            answer += a * b ** (a - 1)
    return answer


def integrate(exps, b):
    answer = 0
    for a in exps:
        if (-1 - EPS) < a < (-1 + EPS):
            answer += math.log(b)
        else:
            answer += b ** (a + 1) / (a + 1)
    return answer


if __name__ == '__main__':
    _ = int(input())
    b = float(input())
    exps = list(map(float, input().split()))
    print("{:.10f}".format(differentiate(exps, b)))
    print("{:.10f}".format(integrate(exps, b)))
0