Temporarily, Codeforces is operating in a limited mode due to technical reasons (historical data is unavailable). This will be fixed in the next few hours. ×

saptarshikuar2003's blog

By saptarshikuar2003, history, 3 hours ago, In English

1788B — Sum of Two Numbers Let's assume that there is no carry while adding x and y . Denote n=a9⋯a1a0 , x=b9⋯b1b0 , y=c9⋯c1c0 in decimal system. The condition can be changed as the following condition.

  • ai=bi+ci for all 0≤i≤9 . — Sum of bi and sum of ci should differ by at most 1 .

If ai is even, let bi=ci=ai/2 . Otherwise, let bi and ci be ai+12 or ai−12 . By alternating between (bi,ci)=(ai+12,ai−12) and (bi,ci)=(ai−12,ai+12) , we can satisfy the condition where sum of bi and sum of ci differ by at most 1 .

There is an alternative solution. If n is even, divide it into (n2,n2 ). If remainder of n divided by 10 is not 9 , divide it into (n+12,n−12 ). If remainder of n divided by 10 is 9 , recursively find an answer for ⌊n10⌋_- _ which is (x′,y′ ) and the answer will be (10x′+4,10y′+5 ) or (10x′+5,10y′+4 ) depending on what number has a bigger sum of digits.

The following solution has a countertest.

  1. Trying to find x and y by bruteforce from (1,n−1 ). 2. Trying to find x and y by bruteforce from (n+12,n−12 )

A solution that randomly finds (x,y ) passes.

here I just wanted to how recursively I can find the for n/10 floor values please clarify

»
3 hours ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Bro! Please fix your blog. It's unreadable.

Advice:

  1. Try it yourself again.

  2. Ask AI models or your CP friends!

  3. Still not getting the solution? Check the editorial ![](https://codeforces.me/blog/entry/112584)

Happy Coding! ^-^