[ACM]Q10290: {sum+=i++} to Reach N
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
namespace Q10290
{
class Program
{
static private BigInteger n; static private bool ntof; static private BigInteger sum; static private int count;
static void Main(string[] args)
{
for (; ; )
{
labeln: Console.Write("n>>>");
ntof = BigInteger.TryParse(Console.ReadLine(), out n);
if (!ntof) goto labeln;
sum = 0; count = 0;
for (BigInteger i = 1; i <= n; i++)
{
sum = 0;
for (BigInteger j = i; j <= n; j++)
{
sum += j;
if (sum == n) count++;
else if (sum > n) break;
}
}
Console.WriteLine("Ans={0}", count);
}
}
}
}