Rosetta Problems

JOI 2006 予選 問題3

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