N-1번의 일관된 게이트 작동 뒤 1번부터 128번 구간의 빔 전하를 알아내야 한다. 129번부터 512번 구간에서 최대 10번 측정할 수 있고, 검출기는 7자리를 넘으면 값을 감싼다.
어려움9수학정수론조합론구현아직 제출이 없습니다시간 제한4초메모리 제한512 MBOkarin Kyouma is a brilliant scientist working on Medium Hadron Collider (MHC) in Société Européenne de Recherche Nucléaire (SERN). His current experiments aim to unravel the mysterious Stein's gate effect.
MHC consists of a sufficiently large amount of sections arranged on a line and numbered 1,2,3,… along the line. Particle beams traverse through sections in ascending order of section numbers, it takes one second for a beam to pass any section. There are two types of beams which may be present in MHC: electronic beams e− and positronic beams e+.
Initially, there is a single electronic beam in the beginning of the first section of MHC. Each section is affected by the Stein's gate effect. When a particle beam goes through the center of section i>1, the gate is triggered and creates another beam in the center of section i−1. This new beam is either the same or inverted (that is, e+ instead of e−, and vice versa). The new beam moves in the same direction and with the same speed as the initial beam. Beam recreation is coherent: at each step, either all sections produce the same beams or all sections produce inverted beams.
Then created beam interferes with the one already present in the section, if any. Beams of the same type merge, while beams of opposite types annihilate. Formally, we may say that a single electronic beam has charge −1, single positronic beam has charge +1, and an "empty" beam has charge 0. The result of collision of beams with charges α and β will be a beam with charge γ=α+β. Here are a few examples:
The end of the N-th second of experiment approaches. So, the Stein's gate effect was activated exactly N−1 times, but the initial electronic beam is yet in the section numbered N. Okarin wants to measure the total charge of beams traversing through some sections but, unfortunately, measurement tools for sections 1 through 128 are out of reach. Okarin needs these values urgently, but he only has time to check the measurements in at most 10 sections. Moreover, he does not have proper permission to get measurements in sections beyond number 512, thus he may only ask about sections from 129 to 512 inclusively.
You need to help Okarin recover measures in sections from 1 to 128. Note that detectors in sections are not perfect, and can only show 7 digits and the sign. Thus, for example, if a detector approaches +10,000,000, it will show −9,999,999 instead. After that, +10,000,001 will be shown as −9,999,998, and so on.
The example for this problem has N=4 and does not coincide with the actual first test case. In the example, the Stein's gate effect was activated three times. Let us assume that its first and second activations produced the same beams, and the third activation produced inverted beams. Then:
In the example, the solution asks what are the charges in sections from 1 to 5, and then outputs the charges in sections from 1 to 4.
Recall that, in the actual test cases, the solution can ask only about sections 129 to 512, and must then output the measurements in sections 1 to 128.