BC153 [NOIP2010]数字统计
描述
 牛牛拿到了一个字符串。
 他每次“点击”,可以把字符串中相邻两个相同字母消除,例如,字符串"abbc"点击后可以生成"ac"。
 但相同而不相邻、不相同的相邻字母都是不可以被消除的。
 牛牛想把字符串变得尽可能短。他想知道,当他点击了足够多次之后,字符串的最终形态是什么?
 输入描述:
 一个字符串,仅由小写字母组成。(字符串长度不大于300000)
 输出描述:
 一个字符串,为“点击消除”后的最终形态。若最终的字符串为空串,则输出0。
 
#include <iostream>
using namespace std;
int main()
{
	int l, r;
	cin >> l >> r;
	int cnt = 0;
	for (int i = l; i <= r; i++)
	{
		int n = i;
		while (n)
		{
			if (n % 10 == 2) cnt++;
			n = n / 10;
		}
	}
	cout << cnt << endl;
	return 0;
}
NC313 两个数组的交集

class Solution {
  public:
    /**
    * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
    *
    *
    * @param nums1 int整型vector
    * @param nums2 int整型vector
    * @return int整型vector
    */
    vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
// write code here
        unordered_set<int> hash;
        vector<int> ans;
        for (int x : nums1)
            hash.insert(x);
        for (int y : nums2) {
            if (hash.find(y) != hash.end()) {
                ans.push_back(y);
            }
            hash.erase(y);
        }
        return ans;
    }
};
AB5 点击消除

#include <iostream>
#include<string>
using namespace std;
int main() {
    string s, st;
    cin >> s;
    for (auto ch : s) {
        if (st.size() && st.back() == ch) st.pop_back();
        else st += ch;
    }
    cout << (st.size() == 0 ? "0" : st) << endl;
    return 0;
}












![[Win11·Copilot] Win11 系统更新重启后任务栏 Copilot 图标突然消失 | 解决方案](https://img-blog.csdnimg.cn/direct/fca89418431140539a24f3f6ad80b7e4.jpeg#pic_center)






