競技プログラミング用のライブラリ    次のライブラリへ    前のライブラリへ

001-06 BigIntegerクラスのサンプル


BigIntegerクラスのサンプルです。


C#のソース

using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics; // これがないとコンパイルエラーになるので注意

class Program
{
    static void Main()
    {
        var InsBigInteger1 = new BigInteger(1);
        for (int I = 1; I <= 9999; I++) {
            InsBigInteger1 *= 2;
        }
        Console.WriteLine(InsBigInteger1);
        // 997531558440379192441871081341792541911748・・・

        // 文字列からの変換の方法
        var InsBigInteger2 = BigInteger.Parse("12345678901234567890");
    }
}