solve AOJ0189
modify AOJ2170(WA)