10 x + y=25 1475
Under the condition of x and y are integer, want to find out the x, y all the possible values,,,
How to write the written in Python, code?? Thank you very much!!!!!
CodePudding user response:
Integer x,When x is equal to 15, greater than 1475
So, exhaustive all 1 & lt;=x & lt;
=15 of the integerJudgment is an integer, y so, added to the dictionary
CodePudding user response:
X_times=# 10 x n multiple
Y_times=25 # y n ratio
Xy_sum=1475
X_range=xy_sum//x_times + 1
Y_range=xy_sum//y_times + 1
Serial_num=0
For the x in the range (0, x_range) :
For y in range (0, y_range) :
If x_times * x + y_times * y==xy_sum:
Serial_num +=1
Print (" serial number={} : when x={}, y={}, meet the conditions of {} {} x + y=1475 ". The format (serial_num, x, y, x_times, y_times))
CodePudding user response:
Print statements to fine-tune the ha:So x_times and y_times and xy_sum value you can modify!
X_times=# 10 x n multiple
Y_times=25 # y n ratio
Xy_sum=1475
X_range=xy_sum//x_times + 1
Y_range=xy_sum//y_times + 1
Serial_num=0
For the x in the range (0, x_range) :
For y in range (0, y_range) :
If x_times * x + y_times * y==xy_sum:
Serial_num +=1
Print (" serial number={} : when x={}, y={}, meet the conditions of x + y={} {} {} ". The format (serial_num, x, y, x_times y_times, xy_sum))
CodePudding user response:
Solving mathematics problems in mathematical way, this should eliminate the situation of negative integer about share, 2 x + 5=295, y x and y as an integer, and zero integer, analysis of x is 0, y=59 at this time, but not for 0, y and y must have for odd number, the minimum y is 1, so the result is x={0, 5, 10,... 145}, corresponding values for {57, 59, 55 y... 1},CodePudding user response:
Excuse me,X, y is a positive integer or an integer?
Integer solutions of words should be infinitely many
If it is a positive integer code written 3 floor is very good, the equivalent of y=x + 1475/25-10/25, for the first quadrant positive integer solutions
CodePudding user response:
10 x + y=25 1475As the positive integer, X from 0 to 148
Y from 0 to 59
Traversal solution can
For x in the range (148 + 1) :
For y in range (59 + 1) :
If (10 * 25 * x + y)==1475:
Print (x, y)
CodePudding user response:
0 595 57
10 55
15 53
20 51
25 49
30 47
35 to 45
40 43
45 41
50 39
55 37
60 35
33 65
31 70
29 75
27 80
85 25
23 90
21 95
100 19
17 105
15 110
13 115
11 120
125
130 7
135
140
145 1
CodePudding user response:
If not consider negative integer x and y are & gt;=0, when x=0, 1475/25=59, when y=0, 1475/10=147.5 the integer is 148, so the code is as follows:
For x in the range (148 + 1) :
For y in range (59 + 1) :
If (10 * 25 * x + y)==1475:
Print (x, y)