시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 126 26 24 25.263%

문제

상근이는 공부를 못하는 학생이다. 왜 공부를 못할까? 상근이의 옆에서 수업을 같이 듣는 선영이는 다음과 같이 말했다.

"상근이는 수업시간에 수업을 듣지 않아요. 수업시간 내내 종이에 숫자로 원을 만들고 있지요."

왜 이런 짓을 하고 있는 것일까? 상근이는 생각나는 대로 숫자를 쓰는 것이 아니다. 자신만의 규칙이 있다.

먼저 양의 정수 N개를 머리 속에 생각한다. 그 다음 공책을 한 장 찢고 거기에 생각한 숫자를 원 모양으로 적는다. 상근이는 이 원을 숫자 원이라고 부른다.

여기까지는 연습에 불과하다. 이제 공책을 한 장 더 찢는다. 그 다음, 각 숫자에 양 옆의 숫자를 더해서 새로운 원을 만든다.

상근이는 원을 만드는데 너무 집중을 했고, 교수님은 상근이의 종이를 뺏아가 버렸다. 영리한 상근이는 두 장 중에서 한 장을 숨겼고, 첫 번째 종이만 뺏겼다. 

상근이는 두 번째 종이를 이용해서 첫 번째 종이의 숫자를 다시 만드려고 한다. 두 번째 종이에 써 있는 수가 주어졌을 때, 첫 번째 종이에 써 있는 수를 구하는 프로그램을 작성하시오.

입력

첫째 줄에 두 번째 숫자 원에 써있는 수의 개수 N이 주어진다. (3 ≤ N ≤ 10,000)

다음 N개 줄에는 원에 써 있는 수가 원을 이루는 순서대로 주어진다. 숫자는 109보다 작은 자연수이다.

입력으로 주어지는 숫자 원을 만드는 첫 번째 숫자 원은 유일하지 않을 수 있다. 하지만, 항상 답이 존재하는 경우만 주어진다.

출력

상근이가 만든 첫 번재 원에 써 있는 수를 N줄에 걸쳐 출력한다. 수는 항상 양의 정수이어야 한다.

원을 회전시킬 수는 없다. 따라서, 처음 세 숫자의 합은 입력으로 주어지는 숫자 중 두 번째 숫자와 같아야 한다.

예제 입력 1

4
20
15
17
14

예제 출력 1

5
8
2
7
W3sicHJvYmxlbV9pZCI6IjMwMDciLCJwcm9ibGVtX2xhbmciOiIwI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RlZ2VycyBpbiB0aGUgcmluZ3MuJm5ic3A7PFwvcD5cclxuXHJcbjxwPkVhY2ggb2YgdGhlIGZvbGxvd2luZyBOIGxpbmVzIGNvbnRhaW5zIGFuIGludGVnZXIgbGVzcyB0aGFuIDEwPHN1cD45PFwvc3VwPiAob25lIGJpbGxpb24pLiBUaGVzZSBudW1iZXJzLCBpbiBvcmRlciwgZm9ybSB0aGUgc2Vjb25kIHJpbmcuJm5ic3A7PFwvcD5cclxuXHJcbjxwPlRoZSBpbnB1dCB3aWxsIGJlIHN1Y2ggdGhhdCBhIHNvbHV0aW9uLCBhbHRob3VnaCBub3QgbmVjZXNzYXJpbHkgdW5pcXVlLCB3aWxsIGFsd2F5cyBleGlzdC48XC9wPlxyXG4iLCJvdXRwdXQiOiI8cD5PdXRwdXQgdGhlIG9yaWdpbmFsIHJpbmcgb24gTiBsaW5lcy4gVGhlIG51bWJlcnMgbXVzdCBiZSBwb3NpdGl2ZS4mbmJzcDs8XC9wPlxyXG5cclxuPHA+Um90YXRpbmcgdGhlIHJpbmcgaXMgbm90IGFsbG93ZWQuIEZvciBleGFtcGxlLCB0aGUgc3VtIG9mIHRoZSBmaXJzdCB0aHJlZSBvdXRwdXQgbnVtYmVycyBtdXN0IGJlIGVxdWFsIHRvIHRoZSBzZWNvbmQgbnVtYmVyIGluIHRoZSBpbnB1dCByaW5nLiZuYnNwOzxcL3A+XHJcblxyXG48cD5Ob3RlOiBUaGUgc29sdXRpb24gbmVlZCBub3QgYmUgdW5pcXVlLiZuYnNwOzxcL3A+XHJcbiIsImhpbnQiOiIiLCJvcmlnaW5hbCI6IjEiLCJwcm9ibGVtX2xhbmdfY29kZSI6Ilx1YzYwMVx1YzViNCJ9XQ==

출처

Contest > Croatian Open Competition in Informatics > COCI 2007/2008 > Contest #2 5번

  • 문제를 번역한 사람: baekjoon
  • 문제의 오타를 찾은 사람: gumgood