IMO you should give credits to the original author of that text and also provide the link of that website. There are two reasons behind this,
$1.$ Legal issues
$2.$ Morality
Mostly, material in websites like StackExchange fall under some Creative Commons license. The problem is that there are several types of CC licences. Some of them may have copyright issues. I do not know details about these things. That's why I always give credits to the original author. IIRC some CC license only allow the use of their material for non-profit organisation. I'd give the credits even if there weren't no legal issues -- morality!
Putting the moral values aside, one would have to study the details of the licence if they wants not to give the credits to the author.
Edit
What matters is, whether you are answering on the behalf of that XYZ's answer, or not. It is obvious that if you are copying XYZ's answer verbatim, then you ought to give the credits, morally and legally. What if you were not copying that answer verbatim? You still have to give proper attribution, because you have build your answer upon XYZ's. Note that some CC licences do not allow any modifications in their text.
Now let's come to your specific example. "How to find $∫_0^1x^2dx$"? The simpler isn't better this time. I would answer it as:
"Use the standard farmula $\int _a^b x^ndx= \left[\dfrac{x^{n+1}}{n+1}\right]_a^b$, s.t. $x \in \mathbb{Z} - \{-1\}$"
There is a minute probability that my answer matches exactly world by word to XYZT's answer; but I didn't copied that or even used that XYZT's answer. So I won't care about it; whatever anyone would say. If I had answered by first reading XYZ's and XYZT's posts then I would give credits to them -- this scenario would be the rarest because of the type of your example. In these type of questions "XYZ" wouldn't be the only reference that I'd use. Implicitly I'd be using some text of the original discoverer of that standard formula, or some book as my reference. But I'd not give credits to anyone because that would be too much. Do I need to quote Principia Mathematicia every time I use Newton's Laws. Legally I should, but I won't, because every one knows that Newton discovered them.
If the matter is that I had never known myself how to solve $\int x^2 dx$, and I saw the question on MSE, then I googled the same and went to "XYZ" website, say this website and knew how to solve it. Then if I were going to answer that question on MSE then I'd for sure give credits to "XYZ's" text's author. Because for me $\int x^2 dx$ could be an unsolved or rare or difficult mathematical problem. If I didn't give credits then people would thought that I discovered that solution; which would not be the case.
Summary:
When should one at all give credits to XYZ's answer's author,
- When they copied it verbatim.
- If they had build their answer upon XYZ's. And it becomes mandatory when XYZ's answer contain something original, rare, unique etc.