結果

問題 No.3362 積分!!!
コンテスト
ユーザー IT2006
提出日時 2025-10-29 16:54:23
言語 C#
(.NET 8.0.404)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 1,287 bytes
コンパイル時間 7,768 ms
コンパイル使用メモリ 169,844 KB
実行使用メモリ 187,528 KB
最終ジャッジ日時 2025-11-17 20:36:23
合計ジャッジ時間 9,807 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (114 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using System.Numerics;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Formats.Asn1;
using System.Globalization;
using System.Linq;

namespace algorism
{
    class Program
    {
        static void Main()
        {
            string[] input1 = Console.ReadLine().Split(" ");
            int N = int.Parse(input1[0]);
            int A = int.Parse(input1[1]);
            int B = int.Parse(input1[2]);

            BigInteger temp = 0;
            BigInteger factorial = 1;

            // factorial = (N+1)!
            for (int i = 1; i <= N + 1; i++) factorial *= i;

            for (int i = 0; i < N + 1; i++)
            {
                BigInteger nanika = BigInteger.Parse(Console.ReadLine());
                BigInteger kaijyou = factorial / (i + 1);
                BigInteger diff = BigInteger.Pow(B, i + 1) - BigInteger.Pow(A, i + 1);
                temp += diff * nanika * kaijyou;
            }

            // ↓ floor除算で切り捨て
            BigInteger ans = FloorDiv(temp, factorial);
            Console.WriteLine(ans);
        }

        static BigInteger FloorDiv(BigInteger a, BigInteger b)
        {
            if (a >= 0) return a / b;
            else return -(((-a) + b - 1) / b);
        }
    }
}
0