import time
a=time.time()for x in range(100):for y in range(100):for z in range(100):if (x+y+z==100) and (x*5+y*3+z/3==100):
print(x,y,z)
b=time.time()
c= b-a
print(c)
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZuBnL2UDO5kDNzAzNx0iMxUzM1AjM5EDOyMDMwIDMy0yNxUTMwETMvw1MwAjMwIzLcdTM1EDMxEzLcd2bsJ2Lc12bj5ycn9Gbi52YuAjMwIzZtl2Lc9CX6MHc0RHaiojIsJye.png)
优化一下算法之后
import time
a=time.time()for x in range(20):
y= 25 - (7 / 4) *x
z= 100 - x -yif (z % 3 == 0) and (x * 5 + y * 3 + z / 3 == 100):
print(x, y, z)
b=time.time()
c= b -a
print(a, b)
竟然连1ms的时间都不需要了
function calc() {
for (x = 0; x < 100; x++) {
for (y = 0; y < 100; y++) {
for (z = 0; z < 100; z++) {
if ((x + y + z == 100) && (x * 5 + y * 3 + z / 3 == 100)) {
console.log(x, y, z);
}
}
}
}
}
calc()