-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path1237.cpp
More file actions
24 lines (23 loc) · 763 Bytes
/
1237.cpp
File metadata and controls
24 lines (23 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
* // This is the custom function interface.
* // You should not implement it, or speculate about its implementation
* class CustomFunction {
* public:
* // 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)
* int f(int x, int y);
* };
*/
class Solution {
public:
vector<vector<int>> findSolution(CustomFunction& customfunction, int z) {
vector<vector<int>> res;
int y = 1000;
for (int x = 1; x <= 1000; ++x) {
while (y > 1 && customfunction.f(x, y) > z) y--;
if (customfunction.f(x, y) == z) res.push_back({x, y});
}
return res;
}
};