04 2021 档案
摘要:我们需要用到bitset库函数。bitset类型 类似于数组结构,特点是每一位只能由0或者1构成。 定义 bitset < size > b; size是我们指定的大小即位数,按我们所需指定。 使用 使用时我们将整形对其进行赋值即可。 举个栗子,12如果是四位二进制是1100,八位二进制则为0000
阅读全文
摘要:陈旧的代码,今天竟然翻出来了QAQ,渣渣学校只会让写学生管理系统,贴出来希望对大家有用。 #include <bits/stdc++.h> using namespace std; struct node { char stuNum[10]; //学号 char stuName[10];//姓名 c
阅读全文
摘要:解 借助优先队列。 钥匙盒的状态是由老师拿走与放回的操作改变的,每一次输入的w, s, c都包含着两个时刻,s和s+c时刻(放回和归还的时间)。 钥匙盒的变化是随着时间从早到晚来改变的,所以遍历操作改变的时候,时间需要从小到大出现。 如果同一时刻既有老师还钥匙又有老师取钥匙,则老师们会先将钥匙全还回
阅读全文
摘要:解 遍历判断左右与其满足关系 int judge(int x, int y, int z) { return (x < y && x < z) || (x > y && x > z); } // // Created by 29273 on 2021-04-02. // #include "bits
阅读全文
摘要:解 基本操作,不多说 // // Created by 29273 on 2021-04-02. // #include "bits/stdc++.h" using namespace std; int main() { int n, num = 0; cin >> n; while (n) { n
阅读全文
摘要:解 遍历输入数据,存在前后不相等的情况就记录。 // // Created by 29273 on 2021-04-02. // #include "bits/stdc++.h" using namespace std; int a[1001]; int res = 1; int main() {
阅读全文
摘要:解 vector与map结合 map存储数字以及出现个数,利用vector自定义排序函数来排序 // // Created by 29273 on 2021-04-05. // #include "bits/stdc++.h" using namespace std; bool cmp(pair<i
阅读全文
摘要:解 改变输出顺序即可 // // Created by 29273 on 2021-04-02. // #include "bits/stdc++.h" using namespace std; int n, m; int a[1001][1001]; int main() { cin >> n >
阅读全文
摘要:解 模拟题,根据题意来,最好自己造几组测试数据。 先遍历有没有一组座位可以直接满足,没有就从头开始,不考虑连座把空余的座位直接分配(每一组都要分当前剩余座位大于等于和小于需求座位来处理)。 // // Created by 29273 on 2021-04-05. // #include "bits
阅读全文
摘要:解 蓝桥杯接触过一点应该就很简单。这里的代码没有局限于一年的,所以比较长。 重点就是闰年的判断以及在每一月的最后一天边界值的判断。 // // Created by 29273 on 2021-04-05. // #include "bits/stdc++.h" using namespace st
阅读全文
摘要:解 维护一个标记数组,每个人在t有时间时a[t]就加一,那么二者都有时间的时候就是a[t] == 2。 // // Created by 29273 on 2021-04-05. // #include "bits/stdc++.h" using namespace std; int a[10000
阅读全文
摘要:解 第一次想到的是前缀和,维护每一次梳果之后的个数,虽然正确,但最后发现没有很大的必要。 围成一个圈自然是和取余有关啦。 // // Created by 29273 on 2021-04-06. // #include "bits/stdc++.h" using namespace std; co
阅读全文
摘要:解 使用set来存储每一个点,通过查询其八个方向是否存在点来解题 // // Created by 29273 on 2021-04-07. // #include "bits/stdc++.h" using namespace std; int dir[8][2] = {{0, 1}, {0, -
阅读全文
摘要:解 用map来存储同一位置的u和v即可,key是index。注意可能溢出。 map<int, pair<int, int>> m; // // Created by 29273 on 2021-04-07. // #include "bits/stdc++.h" using namespace st
阅读全文
摘要:解 简单模拟 // // Created by 29273 on 2021-04-05. // #include "bits/stdc++.h" using namespace std; char a[13]; int change(char ch) { return ch - '0'; } int
阅读全文
摘要:加上题目审核不通过,我吐了QAQ 解 运用list的结构,使用erase和emplace_front 操作完成窗口的位置变化。 // // Created by 29273 on 2021-04-05. // #include "bits/stdc++.h" using namespace std;
阅读全文
摘要:问题描述 有 N 个非零且各不相同的整数。请你编一个程序求出它们中有多少对相反数(a 和 -a 为一对相反数)。 输入格式 第一行包含一个正整数 N。(1 ≤ N ≤ 500)。 第二行为 N 个用单个空格隔开的非零整数,每个数的绝对值不超过1000,保证这些整数各不相同。 输出格式 只输出一个整数
阅读全文
摘要:问题描述 给定n个正整数,找出它们中出现次数最多的数。如果这样的数有多个,请输出其中最小的一个。 输入格式 输入的第一行只有一个正整数n(1 ≤ n ≤ 1000),表示数字的个数。 输入的第二行有n个整数s1, s2, …, sn (1 ≤ si ≤ 10000, 1 ≤ i ≤ n)。相邻的数用
阅读全文
摘要:C++ 11 标准新增加的操作函数,在使用效果上与push_back大致一样,只不过底层实现不同。 emplace操作 emplace操作大致包含三个成员:emplace_front、emplace 和 emplace_back。分别对应与之前的push_front、insert 和push_bac
阅读全文

浙公网安备 33010602011771号