Let $f(x)$ be a continuous function such that $\int_0^1 f(x)\ dx=1.$ Find $f(x)$ for which $\int_0^1 (x^2+x+1)f(x)^2dx$ is minimized.
1. **Given Conditions and Objective**:
   - We are given that \( f(x) \) is a continuous function such that \( \int_0^1 f(x) \, dx = 1 \).
   - We need to find \( f(x) \) that minimizes \( \int_0^1 (x^2 + x + 1) f(x)^2 \, dx \).

2. **Applying the Cauchy-Schwarz Inequality**:
   - The Cauchy-Schwarz inequality for integrals states:
     \[
     \left( \int_a^b u(x) v(x) \, dx \right)^2 \leq \left( \int_a^b u(x)^2 \, dx \right) \left( \int_a^b v(x)^2 \, dx \right)
     \]
   - Let \( u(x) = f(x) \) and \( v(x) = \frac{1}{\sqrt{x^2 + x + 1}} \). Then:
     \[
     \left( \int_0^1 f(x) \, dx \right)^2 = \left( \int_0^1 f(x) \cdot \frac{1}{\sqrt{x^2 + x + 1}} \cdot \sqrt{x^2 + x + 1} \, dx \right)^2
     \]
     \[
     \leq \left( \int_0^1 (x^2 + x + 1) f(x)^2 \, dx \right) \left( \int_0^1 \frac{1}{x^2 + x + 1} \, dx \right)
     \]

3. **Simplifying the Inequality**:
   - Given \( \int_0^1 f(x) \, dx = 1 \), we have:
     \[
     1 = \left( \int_0^1 f(x) \, dx \right)^2 \leq \left( \int_0^1 (x^2 + x + 1) f(x)^2 \, dx \right) \left( \int_0^1 \frac{1}{x^2 + x + 1} \, dx \right)
     \]
   - Let \( I = \int_0^1 (x^2 + x + 1) f(x)^2 \, dx \) and \( J = \int_0^1 \frac{1}{x^2 + x + 1} \, dx \). Then:
     \[
     1 \leq I \cdot J
     \]
     \[
     I \geq \frac{1}{J}
     \]

4. **Evaluating \( J \)**:
   - To find \( J \), we complete the square for \( x^2 + x + 1 \):
     \[
     x^2 + x + 1 = \left( x + \frac{1}{2} \right)^2 + \frac{3}{4}
     \]
   - Let \( u = x + \frac{1}{2} \), then \( du = dx \) and the limits change from \( x = 0 \) to \( x = 1 \) to \( u = \frac{1}{2} \) to \( u = \frac{3}{2} \):
     \[
     J = \int_{\frac{1}{2}}^{\frac{3}{2}} \frac{1}{u^2 + \frac{3}{4}} \, du = \frac{2}{\sqrt{3}} \int_{\frac{1}{2}}^{\frac{3}{2}} \frac{1}{\left( \frac{2u}{\sqrt{3}} \right)^2 + 1} \, du
     \]
     \[
     = \frac{2}{\sqrt{3}} \cdot \frac{\sqrt{3}}{2} \left[ \arctan \left( \frac{2u}{\sqrt{3}} \right) \right]_{\frac{1}{2}}^{\frac{3}{2}}
     \]
     \[
     = \left[ \arctan \left( \frac{2u}{\sqrt{3}} \right) \right]_{\frac{1}{2}}^{\frac{3}{2}} = \arctan \left( \frac{3}{\sqrt{3}} \right) - \arctan \left( \frac{1}{\sqrt{3}} \right)
     \]
     \[
     = \arctan \left( \sqrt{3} \right) - \arctan \left( \frac{1}{\sqrt{3}} \right) = \frac{\pi}{3} - \frac{\pi}{6} = \frac{\pi}{6}
     \]
   - Therefore, \( J = \frac{\pi}{6} \).

5. **Finding the Minimum Value of \( I \)**:
   - From the inequality \( I \geq \frac{1}{J} \):
     \[
     I \geq \frac{1}{\frac{\pi}{6}} = \frac{6}{\pi}
     \]

6. **Condition for Equality in Cauchy-Schwarz**:
   - Equality in the Cauchy-Schwarz inequality holds if and only if \( \sqrt{x^2 + x + 1} f(x) = k \cdot \frac{1}{\sqrt{x^2 + x + 1}} \) for some constant \( k \):
     \[
     f(x) = \frac{k}{x^2 + x + 1}
     \]
   - Using the condition \( \int_0^1 f(x) \, dx = 1 \):
     \[
     \int_0^1 \frac{k}{x^2 + x + 1} \, dx = 1
     \]
     \[
     k \cdot \int_0^1 \frac{1}{x^2 + x + 1} \, dx = 1
     \]
     \[
     k \cdot \frac{\pi}{6} = 1 \implies k = \frac{6}{\pi}
     \]
   - Therefore, the function \( f(x) \) that minimizes the integral is:
     \[
     f(x) = \frac{6}{\pi (x^2 + x + 1)}
     \]

The final answer is \( \boxed{ f(x) = \frac{6}{\pi (x^2 + x + 1)} } \).