Quantum Algorithm by DP