Brute force approach (let the computer calculate the problem as stated) for the sample data results in:
count = 25168 % 1007 = 1000
Hence, I dare to state that "Module" means
modulo.
Cheers
Andi
PS: The code (a quick and dense hack to get going):
static int Loop(int x, List<int> v, Func<bool> check)
{
if (x == 0) return check() ? 1 : 0;
int pos = v.Count() - x;
return Enumerable.Range(0, 10)
.Aggregate(0, (r, i) =>
{ v[pos] = i; return r += Loop(x - 1, v, check); });
}
static void CheckProblem(int n, params Tuple<int, int>[] req)
{
List<int> v = new List<int>(new int[n]);
int count = Loop(n, v, ()=>
req.Aggregate(true, (r, p) => r && v[p.Item1] <= v[p.Item2]));
Console.WriteLine("count = {0} % 1007 = {1}", count, count % 1007);
}
static void Main(string[] args)
{
Func<int, int, Tuple<int, int>> r = (a, b) => new Tuple<int, int>(a, b);
CheckProblem(6, r(1,3), r(0,1), r(2,4), r(0,4), r(2,5), r(3,4), r(0,2));
}