/*
* @lc app=leetcode.cn id=1237 lang=typescript
*
* [1237] 找出给定方程的正整数解
*/
// @lc code=start
/**
* // This is the CustomFunction's API interface.
* // You should not implement it, or speculate about its implementation
* class CustomFunction {
* f(x: number, y: number): number {}
* }
*/
function findSolution(customfunction: CustomFunction, z: number): number[][] {}
// @lc code=end
function findSolution(customfunction: CustomFunction, z: number): number[][] {
const res: [number, number][] = []
const check = (x: number, y: number) => customfunction.f(x, y)
for (let i = 1, j = 1000; i <= 1000 && j; i++) {
while (j && check(i, j) > z) j--
if (j && check(i, j) === z) res.push([i, j])
}
return res
}