Date: 2024-10-14 This article explains modular arithmetic operations in Java, crucial for handling large numbers in competitive programming. It covers modular addition, subtraction, multiplication, and exponentiation, emphasizing the use of the modu...
🧠 What is an AND Gate? In digital logic, an AND gate is a basic logic gate that outputs: 1 (True) only if all of its inputs are 1 0 (False) if even one input is 0 🔧 Truth Table for 2-input AND Gate: ABA AND B 000 010 100 111 For mor...
// A journey, not a checklist A few months ago, I started taking DSA — Data Structures and Algorithms — more seriously. Not because I had a tech interview coming up. And not because someone told me to. I just started noticing a pattern. Whether it wa...
"Bro, why are we even learning sorting when we have sort()?"— Me, a few months ago Hey everyone! 👋 I'm Ritam (or just a random 19-year-old trying to survive C++), and today we’re talking about something that sounds boring but is actually weirdly sa...
This is just a little humble blog post writing about solving this problem. Here’s the link if you want to give it a try. Problem Statement Art critics worldwide have only recently begun to recognize the creative genius behind the great bovine painter...
废掉了,拼尽全力无法战胜,做的时候感觉自己差点爆零,以 3 / 8 的优异成绩拿下榜一。这套题前面的题都是主打一个直觉上的欺骗,后面难的不会做。 A. 序列重排 首先,结论是答案只可能是 0, 1, 2。 序列中 0 的个数不超过 \(\lfloor \frac{n + 1}{2} \rfloor\),把 0 穿插到其他数中间肯定是可以放得下的,所以答案是 0; 如果不满足上述条件,0 不能都穿插到其他数中间,那么一定有相邻的数加起来是 0,只能考虑剩余的数,我们要尽可能空出来最小的数。首先...
A. 最大公约数 直接枚举 1 ~ n 对于每一个数从他不等于自己的约数里面找个最大的,然后全部取个 max。 #include <iostream> #include <cmath> using namespace std; int main() { int n, res = 1; cin >> n; for (int i = 1; i <= n; ++i) { int l = sqrt(i); for (int j = 2; j <...
差点就 ak 了,有点可惜,感谢学姐手下留情😭。 A. Number Maximization 签到题 * 1 #include <iostream> #include <algorithm> using namespace std; int main() { string s; cin >> s; sort(s.begin(), s.end(), greater<char>()); cout << s << endl; return 0; } B...
Dynamic Programming (DP) is a powerful technique used to solve problems that involve making a sequence of decisions, often with overlapping sub problems. It’s widely regarded as a challenging concept, but with the right approach, it becomes a highly ...
A. Lucky 7 一道签到题。 #include <iostream> using namespace std; bool cont(int n) { for (char c : to_string(n)) { if (c == '7') return true; } return false; } int main() { int n; cin >> n; bool c1 = cont(n), c2 = n % 7 ==...