>>55
そりゃICPC(の模擬戦)の問題にも出たぐらいベタだしねぇ
http://old.atcoder.jp/problem/detail/110
他人の宿題片付けるほどの住人ならちょちょっとできるでしょ