Quantum algorithm for credit valuation adjustments