wakanda-forever's blog

By wakanda-forever, history, 3 weeks ago, In English

Hello Codeforces!!!

We are delighted to invite you to participate in Codeforces Round 1095 (Div. 2), which will be held on Apr/28/2026 17:35 (Moscow time). You will be given $$$7$$$ problems, including one split into two subtasks (not necessarily placed adjacently), and $$$2$$$ hours $$$15$$$ minutes to solve them. This round will be rated for the participants with a rating lower than 2100.

The problems are authored and prepared by wakanda-forever and wuhudsm.

The scoring distribution is as follows:

A B C D E F G
$$$500$$$ $$$750$$$ $$$1500$$$ $$$2000$$$ $$$2500$$$ $$$2500$$$ $$$2500$$$

We would like to express our sincere thanks to the following individuals for their contributions and for making this round possible:

We hope you take part in the round and enjoy solving the problems. Good Luck and Have Fun!

UPD: Hacks will be disabled for the problems A to E.

UPD: Editorial

UPD: Congratulations to the winners!!!

Top 5 overall:

Top 5 rated participants:

First solves:

Full text and comments »

  • Vote: I like it
  • +192
  • Vote: I do not like it

By wakanda-forever, 3 weeks ago, In English

Thanks for participating. We hope you liked the problems and enjoyed the round.

2226A - Disturbing Distribution

Idea: wakanda-forever
Preparation: wakanda-forever
Solution: wakanda-forever

Solution
Implementation
Rate The Problem!

2226B - Everything Everywhere

Idea: wakanda-forever
Preparation: wakanda-forever
Solution: wakanda-forever

Solution
Implementation
Rate The Problem!

2226C - Mental Monumental (Easy Version)

Idea: wakanda-forever
Preparation: wakanda-forever
Solution: wakanda-forever

Solution
Implementation
Rate The Problem!

2226D - Reserved Reversals

Idea: wakanda-forever
Preparation: wakanda-forever
Solution: wakanda-forever

Solution
Implementation
Rate The Problem!

2226E - Mental Monumental (Hard Version)

Huge thanks to chromate00 for suggesting this task.
Preparation: wakanda-forever
Solution: Proof_by_QED

Solution
Implementation
Rate The Problem!

2226F - Inversion Invasion

Idea: wuhudsm
Preparation: wuhudsm, wakanda-forever
Solution: wakanda-forever

Solution
Implementation
Rate The Problem!

2226G - Stop Spot

Idea: wuhudsm
Preparation: wuhudsm, wakanda-forever
Solution: wuhudsm

Solution
Implementation
Rate The Problem!

Full text and comments »

  • Vote: I like it
  • +86
  • Vote: I do not like it

By wakanda-forever, 7 months ago, In English

Hello, Codeforces!

I am very excited to invite you to our contest Codeforces Round 1059 (Div. 3), which starts on 17.10.2025 17:35 (Московское время). You will be given $$$2$$$ hours and $$$15$$$ minutes to solve $$$8$$$ problems.

The problems were authored and prepared by wakanda-forever, wuhudsm, tridipta2806 and frostcat.

Note that at least one of the problems will be interactive. So if you are unfamiliar with them, please read the guide for interactive problems before the contest.

The round will be hosted by the rules of educational rounds (extended ICPC). Thus, all solutions will be judged on preliminary tests during the round, and after the round, there will be a 12-hour phase of open hacks. After the open hack phase, all accepted solutions will be rejudged on successful hacks. Also, note that there is no score distribution — rank will be determined by the number of problems solved, followed by penalty; wrong submissions will incur the usual penalty of 10 minutes, following the rules of educational rounds.

Remember that only the trusted participants of the third division will be included in the official standings table. As it is written by the link, this is a compulsory measure for combating unsporting behavior. To qualify as a trusted participant of the third division, you must:

  • take part in at least five rated rounds (and solve at least one problem in each of them)
  • do not have a point of 1900 or higher in the rating.

Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you.

We would like to thank:

I wish you the best of luck, and I hope you enjoy the problems!

UPD: Editorial

Full text and comments »

  • Vote: I like it
  • +157
  • Vote: I do not like it

By wakanda-forever, history, 7 months ago, In English

2162A - Beautiful Average

Idea: wakanda-forever Preparation: wakanda-forever

Solution
Implementation

2162B - Beautiful String

Idea: wakanda-forever Preparation: tridipta2806

Solution
Implementation

2162C - Beautiful XOR

Idea: wakanda-forever Preparation: wakanda-forever

Solution
Implementation

2162D - Beautiful Permutation

Idea: wakanda-forever Preparation: wakanda-forever

Solution
Implementation

2162E - Beautiful Palindromes

Idea: wuhudsm Preparation: wakanda-forever

Solution
Implementation

2162F - Beautiful Intervals

Idea: frostcat, wuhudsm, wakanda-forever Preparation: wakanda-forever

Solution
Implementation

2162G - Beautiful Tree

Idea: wakanda-forever Preparation: wakanda-forever

Solution
Implementation

2162H - Beautiful Problem

Idea: wuhudsm Preparation: wuhudsm

Spoiler
Solution
Implementation1(wuhudsm)
Implementation2 (Dominater069)

Full text and comments »

  • Vote: I like it
  • +69
  • Vote: I do not like it

By wakanda-forever, history, 13 months ago, In English

Hello Codeforces,

Recently I was trying to make a number theory problem, I haven't framed the entire question yet but the core part goes something like this $$$-$$$ Given an integer $$$a$$$, find an integer $$$b$$$ ($$$ \le a $$$) such that $$$gcd(a,b)$$$ $$$+$$$ $$$lcm(a,b)$$$ is a prime number.

The condition $$$gcd(a,b)$$$ $$$+$$$ $$$lcm(a,b)$$$ is a prime number boils down to $$$gcd(a,b) = 1$$$ and $$$a \cdot b + 1$$$ is a prime where $$$b \le a$$$.

I tried brute-forcing $$$b$$$ by fixing $$$a$$$ and I found that there exists such $$$b$$$ for all $$$1 \le a \le 10^5$$$. However, I am not sure whether there exists such $$$b$$$ for all $$$a$$$. Does anyone have a formal or intuitive proof why this is happening and is there any approach to find $$$b$$$ given $$$a$$$ ?

Full text and comments »

  • Vote: I like it
  • +37
  • Vote: I do not like it

By wakanda-forever, 17 months ago, In English

Hello everyone. This is my first blog on codeforces.

Coming to the topic, consider the task where you are given an integer $$$n$$$ and you are asked to find the minimum value of $$$k$$$ such that $$$\phi(\phi(\phi...\phi(n)))$$$ $$$= 1$$$ (where $$$\phi$$$ is applied $$$k$$$ times on $$$n$$$ in a nested manner and $$$\phi$$$ is the euler totient function). This task can be solved, but for now let's only focus on finding an upperbound for $$$k$$$.

We have,

$$$ \phi(n) = n \cdot (1-\frac{1}{p_1}) \cdot (1-\frac{1}{p_2}) .... (1-\frac{1}{p_m}) $$$

where $$$n = p_1^{a_1} \cdot p_2^{a_2} \cdot ... p_m^{a_m}$$$ and $$$p_1,p_2...,p_m$$$ are prime factors of $$$n$$$. Proof can be found here.

Now, if $$$n$$$ is even, $$$2$$$ is a prime factor of $$$n$$$ so $$$\phi(n)$$$ $$$\le$$$ $$$\frac{n}{2}$$$ and if $$$n$$$ is odd and $$$n \gt 1$$$, $$$\phi(n) \lt n$$$ and $$$\phi(n)$$$ is even. So we can safely say that $$$\phi(\phi(n)) \le \frac{n}{2}$$$ for all $$$n \gt 1$$$. Repeating this process, it is obvious that after applying $$$\phi$$$ for $$$2 \cdot \lceil \log_2(n) \rceil$$$ times on $$$n$$$, we have $$$\phi(\phi(\phi...\phi(n)))$$$ $$$= 1$$$. So we have $$$k \le 2 \cdot \lceil \log_2(n) \rceil$$$.

We can find an even tighter bound using the fact that $$$\phi(n)$$$ is even for all $$$n \ge 3$$$. So for any $$$n \ge 3$$$, $$$\phi(n)$$$ is even and $$$\phi(\phi(n)) \le \frac{n}{2}$$$, $$$\phi(\phi(\phi(n))) \le \frac{n}{4}$$$, $$$\phi(\phi(\phi(\phi(n)))) \le \frac{n}{8}$$$ and so on. Thus after applying $$$\phi$$$ for $$$\lceil \log_2(n) \rceil$$$ times on $$$n$$$, we have $$$\phi(\phi(\phi...\phi(n)))$$$ $$$= 1$$$. So we have $$$k \le \lceil \log_2(n) \rceil$$$.

I hope atleast someone finds this interesting.

Full text and comments »

  • Vote: I like it
  • +37
  • Vote: I do not like it