結果

問題 No.347 微分と積分
ユーザー bluemeganebluemegane
提出日時 2020-09-04 09:17:09
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 29 ms / 5,000 ms
コード長 627 bytes
コンパイル時間 919 ms
コンパイル使用メモリ 111,932 KB
実行使用メモリ 27,248 KB
最終ジャッジ日時 2024-11-25 01:52:39
合計ジャッジ時間 2,331 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using static System.Math;
using System;

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var b = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, double.Parse);
        var ans1 = 0d;
        var ans2 = 0d;
        for (int i = 0; i < n; i++)
        {
            ans1 += a[i] * Pow(b, a[i] - 1);
            if (a[i] != -1) ans2 += (1 / (a[i] + 1) * Pow(b, a[i] + 1));
            else ans2 += Log(b);
        }
        Console.WriteLine("{0}\n{1}", ans1, ans2);
    }
}
0