http://math.hashcode.ru/questions/17595/%D0%B0%D0%BB%D0%B3%D0%B5%D0%B1%D1%80%D0%B0-%D1%87%D0%B5%D0%BC%D1%83-%D1%80%D0%B0%D0%B2%D0%B5%D0%BD-%D0%BD%D0%BE%D0%BB%D1%8C-%D0%B2-%D0%BD%D1%83%D0%BB%D0%B5%D0%B2%D0%BE%D0%B9-%D1%81%D1%82%D0%B5%D0%BF%D0%B5%D0%BD%D0%B8  -