Equilibrium can be achieved only if the difference between the initial temperatures of tanks is divisible by 3 .
Now, if the difference between the initial temperatues of tanks divided by 3 is less than equal to m then pipe will not burst else pipe will get burst.
Here’s the code :
using namespace std;
int diff=th-tc; if(diff%3==0 && m>=diff/3) cout<<"No\n"; else cout<<"Yes\n"; } return 0;