SPOJ Problem