1237. 找出给定方程的正整数解
代码:
class Solution {
public List<List<Integer>> findSolution(CustomFunction customfunction, int z) {
List<List<Integer>> list = new ArrayList<>();
for (int i = 1; i <= 1000; i++)
{
if (customfunction.f(i, 1) > z) break;
for (int j = 1; j <= 1000; j++)
{
if (customfunction.f(i, j) == z) {
List<Integer> nums = new ArrayList<Integer>();
nums.add(i);
nums.add(j);
list.add(nums);
}
else if (customfunction.f(i, j) > z) break;
}
}
return list;
}
}