Mathematically Hard

LightOJ - 1007