시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 130 27 25 25.253%

문제

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

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

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

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

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

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

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

입력

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

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

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

출력

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

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

예제 입력 1

4
20
15
17
14

예제 출력 1

5
8
2
7
W3sicHJvYmxlbV9pZCI6IjMwMDciLCJwcm9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gdGhlIGludGVnZXIgTiAoMyAmbGU7IE4gJmxlOyAxMDAwMCksIHRoZSBudW1iZXIgb2YgaW50ZWdlcnMgaW4gdGhlIHJpbmdzLiZuYnNwOzxcL3A+XHJcblxyXG48cD5FYWNoIG9mIHRoZSBmb2xsb3dpbmcgTiBsaW5lcyBjb250YWlucyBhbiBpbnRlZ2VyIGxlc3MgdGhhbiAxMDxzdXA+OTxcL3N1cD4gKG9uZSBiaWxsaW9uKS4gVGhlc2UgbnVtYmVycywgaW4gb3JkZXIsIGZvcm0gdGhlIHNlY29uZCByaW5nLiZuYnNwOzxcL3A+XHJcblxyXG48cD5UaGUgaW5wdXQgd2lsbCBiZSBzdWNoIHRoYXQgYSBzb2x1dGlvbiwgYWx0aG91Z2ggbm90IG5lY2Vzc2FyaWx5IHVuaXF1ZSwgd2lsbCBhbHdheXMgZXhpc3QuPFwvcD5cclxuIiwib3V0cHV0IjoiPHA+T3V0cHV0IHRoZSBvcmlnaW5hbCByaW5nIG9uIE4gbGluZXMuIFRoZSBudW1iZXJzIG11c3QgYmUgcG9zaXRpdmUuJm5ic3A7PFwvcD5cclxuXHJcbjxwPlJvdGF0aW5nIHRoZSByaW5nIGlzIG5vdCBhbGxvd2VkLiBGb3IgZXhhbXBsZSwgdGhlIHN1bSBvZiB0aGUgZmlyc3QgdGhyZWUgb3V0cHV0IG51bWJlcnMgbXVzdCBiZSBlcXVhbCB0byB0aGUgc2Vjb25kIG51bWJlciBpbiB0aGUgaW5wdXQgcmluZy4mbmJzcDs8XC9wPlxyXG5cclxuPHA+Tm90ZTogVGhlIHNvbHV0aW9uIG5lZWQgbm90IGJlIHVuaXF1ZS4mbmJzcDs8XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwicHJvYmxlbV9sYW5nX2NvZGUiOiJcdWM2MDFcdWM1YjQifV0=

출처

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

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