DOJ logoDOJ
Problems
Recently added problemsSaved problems
CategoriesDLCContestsGroupsTeamsBoard
Ranking
Solved Problem RankingStreak rankingDOJ Power ranking
Status
Call for TasksLoginRegister
DOJ logoDOJ

Community online judge with OI-style subtask scoring, Elo ratings, and Discord-backed certification.

Problems
ProblemsCategories
Community
ContestsRankingBoardNoticesHost an external contestGuide
Account
LoginRegisterJudge Status
Policy
Terms of ServiceDLC RulesPrivacyAPI documentationLanguage runtimesContest rank rewardsRating and performance
© 2026 DOJ
All rights reserved
Editorial

Hidden Number

Back to problem

Editorial

Compare the parity of the sum of all elements before and after one operation.

If the chosen numbers are a,ba,ba,b, the operation removes them and appends ∣a−b∣|a-b|∣a−b∣. In parity,

∣a−b∣≡a−b≡a+b(mod2).|a-b|\equiv a-b\equiv a+b\pmod 2.∣a−b∣≡a−b≡a+b(mod2).

Therefore, the parity of the sum of all elements never changes.

The initial sequence is (1,2,⋯ ,2x)(1,2,\cdots,2x)(1,2,⋯,2x), so its sum is

1+2+⋯+2x=x(2x+1).1+2+\cdots+2x=x(2x+1).1+2+⋯+2x=x(2x+1).

Since 2x+12x+12x+1 is odd,

x(2x+1)≡x(mod2).x(2x+1)\equiv x\pmod 2.x(2x+1)≡x(mod2).

Thus, the parity of the last remaining element is equal to the parity of xxx.

So f(x)≡x(mod2)f(x)\equiv x\pmod 2f(x)≡x(mod2). From Pi≡ri(mod2)P_i\equiv r_i\pmod 2P, we get

Ki=1−Pi.K_i=1-P_i.Ki​=1−Pi​.

After converting the bit string KKK to an integer, compute

N=C⊕K.N=C\oplus K.N=C⊕K.

Solution written by GPT5.5

i
​
≡
ri​
(mod2)