力扣刷题

Porter Pan

摘要

力扣刷题,每日一道题


  1. 1237. 找出给定方程的正整数解
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
vector<vector<int>> findSolution(CustomFunction& customfunction, int z) {
vector<vector<int>> data_buff;
int count_y = 1000;
for(int x=1;x<=1000;x++)
{
for(int y=count_y;y>0;y-=2)
{
if(customfunction.f(x,y)==z)
{
vector<int> x_y;
x_y.push_back(x);
x_y.push_back(y);
data_buff.push_back(x_y);
count_y = y;
break;
}

}

}
return data_buff;
}
1
2
3
4
5
6
7
8
9
10
11
def findSolution(self, customfunction: 'CustomFunction', z: int) -> List[List[int]]:
data_ = []
y_temp = 1000
for x in range(1,1000):
for y in range(y_temp,0,-1):
if customfunction.f(x,y)==z:
data_.append([x,y])
y_temp =y
break

return data_
文章目录
  1. 1. 摘要
|