The Sensex gained 318.74 points to close at 77,042.82, while the Nifty50 advanced 98.60 points to settle at 23,311.80