-
Notifications
You must be signed in to change notification settings - Fork 7
/
Program.cs
41 lines (40 loc) · 1.09 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
namespace FindPositiveIntegerSolution
{
public class CustomFunction
{
// Returns f(x, y) for any given positive integers x and y.
// Note that f(x, y) is increasing with respect to both x and y.
// i.e. f(x, y) < f(x + 1, y), f(x, y) < f(x, y + 1)
public int f(int x, int y)
{
return 0;
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
public IList<IList<int>> FindSolution(CustomFunction customfunction, int z)
{
int x = 1, y = 1000;
var res = new List<IList<int>>();
while (x <= 1000 && y >= 1)
{
if (customfunction.f(x, y) == z)
{
res.Add(new List<int> { x, y });
x++;
}
else if (customfunction.f(x, y) < z)
x++;
else
y--;
}
return res;
}
}
}