You are viewing a single comment's thread. Return to all comments →
C# Code
using System;
class Program { static ulong GetWays(int n) { ulong[] a = new ulong[n + 1]; a[0] = 1;
for (int j = 1; j < n; j++) { for (int i = j; i <= n; i++) { a[i] = (a[i] + a[i - j]) % 1000000007; } } return a[n] % 1000000007; } static void Main() { int t = int.Parse(Console.ReadLine()); for (int i = 0; i < t; i++) { int n = int.Parse(Console.ReadLine()); ulong ways = GetWays(n); Console.WriteLine(ways); } }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #76: Counting summations
You are viewing a single comment's thread. Return to all comments →
C# Code
using System;
class Program { static ulong GetWays(int n) { ulong[] a = new ulong[n + 1]; a[0] = 1;
}