結果

問題 No.347 微分と積分
ユーザー mban
提出日時 2017-01-01 22:24:34
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 31 ms / 5,000 ms
コード長 850 bytes
コンパイル時間 1,126 ms
コンパイル使用メモリ 105,728 KB
実行使用メモリ 20,352 KB
最終ジャッジ日時 2024-12-16 05:23:16
合計ジャッジ時間 2,654 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;


class Magatro
{

    static int N, B;
    static double[] a;
    static void Main()
    {
        N = int.Parse(Console.ReadLine());
        B = int.Parse(Console.ReadLine());
        a = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        double X1 = 0, X2 = 0;
        for(int i = 0; i < N; i++)
        {
            X1 += a[i] * Math.Pow(B, a[i] - 1.0);
            if (a[i] == -1.0)
            {
                X2 += Math.Log(Math.Abs(B));
            }
            else
            {
                X2 += (1.0 / (a[i] + 1.0)) * Math.Pow(B, a[i] + 1.0);
            }
        }
        Console.WriteLine("{0}\n{1}", X1, X2);
    }
}

0