Rademacher-type formulas for restricted partition and overpartition functions