Project Euler 13
- System.Numerics.BigInteger を使う。
- 部分文字列は、
Substring()
メソッドを使う。
using System; using System.IO; using System.Numerics; public class PE013 { public static void Main() { var x = new BigInteger(0); foreach (string s in File.ReadAllLines("../13.txt")) { x += BigInteger.Parse(s); } Console.WriteLine(x.ToString().Substring(0, 10)); } }
コンパイル時のオプションには、-r:Sysmte.Numerics
を指定する必要があるようです。
% dmcs -r:System.Numerics 013.cs