<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/token-removing-cf-1036-div-1-2-algo-problem-solving-qy6p4bl1d" -->

---
title: Token Removing & CF 1036 (Div. 1 + 2) | algo problem-solving
description: A livestreamed competitive programming session works through Codeforces Round 1036 (Div. 1 + 2) problems. The streamer solves 'Token Removing' with a...
canonical: https://daily.dev/posts/token-removing-cf-1036-div-1-2-algo-problem-solving-qy6p4bl1d
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Token Removing & CF 1036 (Div. 1 + 2) | algo problem-solving | daily.dev
og:description: A livestreamed competitive programming session works through Codeforces Round 1036 (Div. 1 + 2) problems. The streamer solves 'Token Removing' with a...
og:url: https://daily.dev/posts/token-removing-cf-1036-div-1-2-algo-problem-solving-qy6p4bl1d
og:image: https://api.daily.dev/og/posts/Qy6p4BL1D.png
og:image:alt: Token Removing & CF 1036 (Div. 1 + 2) | algo problem-solving
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Token Removing & CF 1036 (Div. 1 + 2) | algo problem-solving

**[Errichto Hard Algorithms](https://daily.dev/sources/errichto2)** · 123 min read · 0 upvotes · 0 comments

## Summary

A livestreamed competitive programming session works through Codeforces Round 1036 (Div. 1 + 2) problems. The streamer solves 'Token Removing' with a right-to-left DP over the number of eaten tokens, multiplying by prefix size times suffix size minus already-eaten count, after an early off-by-one bug. He then tackles 'Subset Multiplication' by iterating backward and expanding a divisor x using GCD, and solves a palindrome-array problem (problem looking at k smallest values) and an array-decrease problem solvable in at most 17 operations. He calls the official editorial for Token Removing bad and plans to post his own explanation. He also mentions upcoming paid August classes on dynamic programming (two groups, around 250 euros) and plans a Division 2 stream on Wednesday, July 9.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=O0qbgoDUj0g>

## Questions this post answers

### How do you solve the Codeforces Token Removing problem with dynamic programming?

Iterate tokens from position n down to 1 and track the number of tokens already eaten as the DP dimension. For each token, decide whether to eat it; if so, multiply the DP value by prefix size times suffix size minus the number of previously eaten tokens. Going right to left is required because it lets you know how many endpoints to the right are already excluded, which isn't possible left to right.

_Developers working through this DP transition can save the walkthrough on daily.dev while debugging their own off-by-one errors._

### How do you find an integer x that Bob multiplied some array elements by in the Subset Multiplication Codeforces problem?

Scan the array from right to left, and whenever a[i] does not divide a[i+1] as required, multiply x by a[i+1] divided by the GCD of a[i] and a[i+1], then retry the division. This grows x by a factor tied to the GCD gap at each violation, and the process terminates in a logarithmic number of expansions since x only grows via prime factors found this way.

_Anyone debugging a similar reverse-GCD recovery approach can reference this exact fix on daily.dev before resubmitting._

## Similar posts on daily.dev

- [MIT Complexity Theorist On Leetcode](https://daily.dev/posts/mit-complexity-theorist-on-leetcode-0hduqghca) · The Developing Dev · 0 upvotes · 0 comments
- [Novak Kaluđerović - Kolja](https://daily.dev/posts/novak-kalu-erovi---kolja-4ccsvuutc) · Lobsters · 0 upvotes · 0 comments
- [The story of Erdős problem \#1026](https://daily.dev/posts/the-story-of-erd-s-problem-1026-mdgrbdzff) · Hacker News · 1 upvotes · 0 comments

---

Tags: [#general-programming](https://daily.dev/tags/general-programming), [#algorithms](https://daily.dev/tags/algorithms), [#c++](https://daily.dev/tags/c++), [#dynamic-programming](https://daily.dev/tags/dynamic-programming)

[View this post on daily.dev](https://daily.dev/posts/token-removing-cf-1036-div-1-2-algo-problem-solving-qy6p4bl1d)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Token Removing \u0026 CF 1036 (Div. 1 + 2) | algo problem-solving","url":"https://daily.dev/posts/token-removing-cf-1036-div-1-2-algo-problem-solving-qy6p4bl1d","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/token-removing-cf-1036-div-1-2-algo-problem-solving-qy6p4bl1d"},"datePublished":"2026-11-15T08:56:00.685Z","dateModified":"2026-11-15T09:23:01.174Z","description":"A livestreamed competitive programming session works through Codeforces Round 1036 (Div. 1 + 2) problems. The streamer solves 'Token Removing' with a...","image":"https://i.ytimg.com/vi/O0qbgoDUj0g/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/O0qbgoDUj0g/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Errichto Hard Algorithms","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Errichto Hard Algorithms","logo":"https://media.daily.dev/image/upload/s--VQMTEj-y--/f_auto,q_auto/v1794732949/logos/errichto2?_a=BAMAMiiw0","url":"https://daily.dev/sources/errichto2"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/token-removing-cf-1036-div-1-2-algo-problem-solving-qy6p4bl1d","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"general-programming,algorithms,c++,dynamic-programming","timeRequired":"PT123M","video":{"@type":"VideoObject","name":"Token Removing \u0026 CF 1036 (Div. 1 + 2) | algo problem-solving","description":"A livestreamed competitive programming session works through Codeforces Round 1036 (Div. 1 + 2) problems. The streamer solves 'Token Removing' with a...","thumbnailUrl":"https://i.ytimg.com/vi/O0qbgoDUj0g/sddefault.jpg","uploadDate":"2026-11-15T08:56:00.685Z","duration":"PT123M","url":"https://api.daily.dev/r/Qy6p4BL1D","embedUrl":"https://www.youtube.com/embed/O0qbgoDUj0g"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Errichto Hard Algorithms","item":"https://daily.dev/sources/errichto2"},{"@type":"ListItem","position":3,"name":"Token Removing \u0026 CF 1036 (Div. 1 + 2) | algo problem-solving"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/token-removing-cf-1036-div-1-2-algo-problem-solving-qy6p4bl1d#faq","mainEntity":[{"@type":"Question","name":"How do you solve the Codeforces Token Removing problem with dynamic programming?","acceptedAnswer":{"@type":"Answer","text":"Iterate tokens from position n down to 1 and track the number of tokens already eaten as the DP dimension. For each token, decide whether to eat it; if so, multiply the DP value by prefix size times suffix size minus the number of previously eaten tokens. Going right to left is required because it lets you know how many endpoints to the right are already excluded, which isn't possible left to right. Developers working through this DP transition can save the walkthrough on daily.dev while debugging their own off-by-one errors."}},{"@type":"Question","name":"How do you find an integer x that Bob multiplied some array elements by in the Subset Multiplication Codeforces problem?","acceptedAnswer":{"@type":"Answer","text":"Scan the array from right to left, and whenever a[i] does not divide a[i+1] as required, multiply x by a[i+1] divided by the GCD of a[i] and a[i+1], then retry the division. This grows x by a factor tied to the GCD gap at each violation, and the process terminates in a logarithmic number of expansions since x only grows via prime factors found this way. Anyone debugging a similar reverse-GCD recovery approach can reference this exact fix on daily.dev before resubmitting."}}]}
```

