문제는 이거고
http://www.acmicpc.net/problem/2776

소스는 이건데 오답이라고 떠
http://ideone.com/PwreG8

어디 틀린데가 있나? 아님 채점도구가 문제냐?