- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Ehab the Xorcist (CF D 1700 Rated) | Bit Manipulation Series #23
Welcome back to the Bit Manipulation series! Today, we are tackling a brilliant Codeforces Div. 2 D problem: "Ehab the Xorcist".
The problem gives us two integers, u (the bitwise XOR of an array) and v (the standard sum of that array), and asks us to construct the shortest possible array that satisfies both conditions.
If you try to brute-force or simulate this, you will be stuck forever. Instead, we are going to unlock the fundamental algebraic relationship between Addition and XOR! In this video, I will prove to you mathematically why v - u must always be an even number, and how we can use that difference to instantly construct an array of length 0, 1, 2, or 3 in O(1) time complexity.
📌 What you will learn in this video:
- The Golden Formula: Understanding why A + B = (A ^ B) + 2 * (A & B).
- Identifying Impossible Cases: Why u greater than v or an odd v - u difference makes the array mathematically impossible (outputting -1).
- The Length 3 Strategy: How to distribute the difference x = (v - u) / 2 to guarantee an array of [u, x, x].
- The Length 2 Optimization: Using the Bit Independence Principle to check if (u & x) == 0, allowing us to compress the array into just [u + x, x].
- C++ Implementation: Writing a clean, O(1) logic tree that instantly solves the problem without any loops.
𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐋𝐢𝐧𝐤: https://codeforces.com/problemset/problem/1325/D
𝐂𝐨𝐝𝐞: https://github.com/yash7xm/cp-topics/tree/master/bit_manipulation
🔗 𝐏𝐥𝐚𝐲𝐥𝐢𝐬𝐭: https://youtube.com/playlist?list=PLtfqa971vD5FCglZmCX6tbAf1BayFzrpv&si=otFZEOGugiMGgCxX
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
👤 WHO IS THIS FOR?
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ CP programmers who want to go beyond "it works" and understand "why it works"
✅ Anyone targeting Codeforces Div 2 C/D or HackerRank hard problems
✅ People who want to build the mathematical intuition behind bit tricks
✅ Students preparing for ICPC, CodeChef, or product company placements
👋 𝐖𝐞𝐥𝐜𝐨𝐦𝐞 𝐭𝐨 𝐭𝐡𝐞 𝐜𝐡𝐚𝐧𝐧𝐞𝐥!
I create content on Competitive Programming, Data Structures & Algorithms (DSA), and now Software Development with Go.
If you find this video helpful, don’t forget to:
👍 Like the video
💬 Comment your doubts/questions (I reply to everyone!)
🔔 Subscribe and turn on notifications to never miss upcoming tutorials
📌 𝐂𝐨𝐧𝐧𝐞𝐜𝐭 𝐰𝐢𝐭𝐡 𝐦𝐞:
🐦 X: https://x.com/Yash_Poonia_
💼 LinkedIn: https://www.linkedin.com/in/yashpoonia/
💻 GitHub: https://github.com/yash7xm
🌐 Discord: https://discord.gg/dAp2PbKFpV
#CompetitiveProgramming #Codeforces #BitManipulation #Algorithms #Cpp
Видео Ehab the Xorcist (CF D 1700 Rated) | Bit Manipulation Series #23 канала Yash Poonia
The problem gives us two integers, u (the bitwise XOR of an array) and v (the standard sum of that array), and asks us to construct the shortest possible array that satisfies both conditions.
If you try to brute-force or simulate this, you will be stuck forever. Instead, we are going to unlock the fundamental algebraic relationship between Addition and XOR! In this video, I will prove to you mathematically why v - u must always be an even number, and how we can use that difference to instantly construct an array of length 0, 1, 2, or 3 in O(1) time complexity.
📌 What you will learn in this video:
- The Golden Formula: Understanding why A + B = (A ^ B) + 2 * (A & B).
- Identifying Impossible Cases: Why u greater than v or an odd v - u difference makes the array mathematically impossible (outputting -1).
- The Length 3 Strategy: How to distribute the difference x = (v - u) / 2 to guarantee an array of [u, x, x].
- The Length 2 Optimization: Using the Bit Independence Principle to check if (u & x) == 0, allowing us to compress the array into just [u + x, x].
- C++ Implementation: Writing a clean, O(1) logic tree that instantly solves the problem without any loops.
𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐋𝐢𝐧𝐤: https://codeforces.com/problemset/problem/1325/D
𝐂𝐨𝐝𝐞: https://github.com/yash7xm/cp-topics/tree/master/bit_manipulation
🔗 𝐏𝐥𝐚𝐲𝐥𝐢𝐬𝐭: https://youtube.com/playlist?list=PLtfqa971vD5FCglZmCX6tbAf1BayFzrpv&si=otFZEOGugiMGgCxX
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
👤 WHO IS THIS FOR?
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ CP programmers who want to go beyond "it works" and understand "why it works"
✅ Anyone targeting Codeforces Div 2 C/D or HackerRank hard problems
✅ People who want to build the mathematical intuition behind bit tricks
✅ Students preparing for ICPC, CodeChef, or product company placements
👋 𝐖𝐞𝐥𝐜𝐨𝐦𝐞 𝐭𝐨 𝐭𝐡𝐞 𝐜𝐡𝐚𝐧𝐧𝐞𝐥!
I create content on Competitive Programming, Data Structures & Algorithms (DSA), and now Software Development with Go.
If you find this video helpful, don’t forget to:
👍 Like the video
💬 Comment your doubts/questions (I reply to everyone!)
🔔 Subscribe and turn on notifications to never miss upcoming tutorials
📌 𝐂𝐨𝐧𝐧𝐞𝐜𝐭 𝐰𝐢𝐭𝐡 𝐦𝐞:
🐦 X: https://x.com/Yash_Poonia_
💼 LinkedIn: https://www.linkedin.com/in/yashpoonia/
💻 GitHub: https://github.com/yash7xm
🌐 Discord: https://discord.gg/dAp2PbKFpV
#CompetitiveProgramming #Codeforces #BitManipulation #Algorithms #Cpp
Видео Ehab the Xorcist (CF D 1700 Rated) | Bit Manipulation Series #23 канала Yash Poonia
ehab the xorcist codeforces div 2 d bit manipulation competitive programming xor vs sum c++ bit manipulation codeforces tutorial algorithms and data structures time complexity O(1) math proof cp cp intuition coding interview prep bitwise AND yash poonia bit manipulation for cp bit manipulation dsa yash bit manipulation
Комментарии отсутствуют
Информация о видео
1 апреля 2026 г. 22:10:08
00:14:37
Другие видео канала





















