시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 1021 477 395 49.068%

문제

회의가 끝났고, 이제 악수를 하는 시간이다. 모든 사람은 직사각형 탁자 하나의 한 면에 앉아있다.

자리를 벗어나지 않고 악수를 하는 방법의 수는 총 몇 가지일까?

각 사람들은 자신의 왼쪽이나 오른쪽에 있는 사람들과 악수를 할 수 있다. (안 할 수도 있다)

입력

첫째 줄에 회의에 참석한 사람의 수 n (1 ≤ n ≤ 10,000,000)이 주어진다.

출력

첫째 줄에 악수를 하는 방법의 수를 출력한다. 수가 매우 커질 수 있기 때문에, 마지막 자리만 출력한다.

예제 입력 1

4

예제 출력 1

5

힌트

n=4인 경우에는 5가지 방법이 있다.

W3sicHJvYmxlbV9pZCI6IjgzOTQiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM1NDVcdWMyMTgiLCJkZXNjcmlwdGlvbiI6IjxwPlx1ZDY4Y1x1Yzc1OFx1YWMwMCBcdWIwNWRcdWIwYWNcdWFjZTAsIFx1Yzc3NFx1YzgxYyBcdWM1NDVcdWMyMThcdWI5N2MgXHVkNTU4XHViMjk0IFx1YzJkY1x1YWMwNFx1Yzc3NFx1YjJlNC4gXHViYWE4XHViNGUwIFx1YzBhY1x1Yjc4Y1x1Yzc0MCBcdWM5YzFcdWMwYWNcdWFjMDFcdWQ2MTUgXHVkMGMxXHVjNzkwIFx1ZDU1OFx1YjA5OFx1Yzc1OCBcdWQ1NWMgXHViYTc0XHVjNWQwIFx1YzU0OVx1YzU0NFx1Yzc4OFx1YjJlNC48XC9wPlxyXG5cclxuPHA+XHVjNzkwXHViOWFjXHViOTdjIFx1YmM5N1x1YzViNFx1YjA5OFx1YzljMCBcdWM1NGFcdWFjZTAgXHVjNTQ1XHVjMjE4XHViOTdjIFx1ZDU1OFx1YjI5NCBcdWJjMjlcdWJjOTVcdWM3NTggXHVjMjE4XHViMjk0IFx1Y2QxZCBcdWJhODcgXHVhYzAwXHVjOWMwXH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