Rosetta Problems

JOI 2006 予選 問題2

https://atcoder.jp/contests/joi2006yo/tasks/joi2006yo_b