上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 17 下一页

2024年9月18日

SMU Autumn 2024 Trial 2

摘要: A. Stand-up Comedian 只要a不为0,那么由于b和c是相互制约的,比如2 5 10 6这个样例,讲完两个笑话以后两个人的容量为2 2,可以选择一个人+1,一个人-1,那么就可进行min(b,c)*2次,进行完后,两个人的容量仍为2,2,最后要看还剩几个笑话可以讲,就是min(a+1 阅读全文

posted @ 2024-09-18 20:18 swj2529411658 阅读(17) 评论(0) 推荐(0)

2024年9月14日

数据结构实验第一周

摘要: 6-1 差距几何 排序的话复杂度要O(n),可以选择桶排序或者计数排序,我选择的是计数排序 比如是 3 2 1 4 4 7 8 6 我开一个数组a [9] (因为最大为8),然后分别对出现的数计数有 a:1 1 1 2 0 1 1 1 0 然后按顺序放回 就是1 2 3 4 4 6 7 8 int 阅读全文

posted @ 2024-09-14 19:09 swj2529411658 阅读(56) 评论(0) 推荐(0)

2024年9月13日

测量算法的运行时间

摘要: #include <stdio.h> #include <time.h> int F(int x); int main() { int x, y; clock_t t1, t2; double t; scanf("%d", &x); t1 = clock(); y = F(x); t2 = cloc 阅读全文

posted @ 2024-09-13 11:33 swj2529411658 阅读(34) 评论(0) 推荐(0)

2024年9月12日

SMU Autumn 2024 Trial 1

摘要: A. Load Balancing 很明显题意要的就是让我们把每个数往平均值靠,这样就保证最大值-最小值最小 但是当sum%n !=0的时候就说明无法每个数都等于sum/n,所以处理的方法就是,先计算这些无法等于sum/n的个数cnt,再算出可以到达sum/n的次数n-cnt,然后算出总代价,再用总 阅读全文

posted @ 2024-09-12 14:24 swj2529411658 阅读(21) 评论(0) 推荐(0)

2024年9月11日

Codeforces Round 971 (Div. 4)

摘要: C. The Legend of Freya the Frog 因为是从x开始跳,贪心的取肯定是直接用max(a,b)/d向上取整然后再乘2,但是要注意,如果再x到达之前,y已经是到达了,也就是某次以后,y都取0,那么最终次数就要-1,因为最后不用再跳y方向的 #include <bits/stdc 阅读全文

posted @ 2024-09-11 21:40 swj2529411658 阅读(84) 评论(0) 推荐(0)

2024年9月7日

Codeforces Round 970 (Div. 3)

摘要: A. Sakurako's Exam 分类讨论即可,当a为奇数,无法消去1,或者a==0且b为奇数时,无法消去2 #include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int,int> pii 阅读全文

posted @ 2024-09-07 23:05 swj2529411658 阅读(85) 评论(0) 推荐(0)

2024年9月2日

数据结构上机题

摘要: 习题1.8 二分查找 Position BinarySearch( List L, ElementType X ) { int l,r,mid; l=1; r=L->Last;//注意这里L不要写成l while(l<=r) { mid=(l+r)/2; if(L->Data[mid]<X) l=m 阅读全文

posted @ 2024-09-02 12:22 swj2529411658 阅读(35) 评论(0) 推荐(0)

2024年8月14日

线段树+懒标记 (区间修改,区间查询)

摘要: 原作者:董晓 P3372 【模板】线段树 1 // 结构体版 #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define N 100005 #define LL long long 阅读全文

posted @ 2024-08-14 20:19 swj2529411658 阅读(28) 评论(0) 推荐(0)

ST表 RMQ问题(区间最大/最小值查询)

摘要: #include <iostream> #include <cstring> #include <algorithm> #include <cmath> using namespace std; int f[100005][22]; int main(){ int n,m; scanf("%d%d" 阅读全文

posted @ 2024-08-14 19:51 swj2529411658 阅读(49) 评论(0) 推荐(0)

2024年8月12日

图论练习题

摘要: [NOIP2003]神经网络 1.题意看懂以后就是计算一下每一个入度0的点最终的状态,并且如果这个状态>0就输出出来,对于阈值,我们可以在一开始就对这些入度的0的点直接减去阈值。 2.然后就是一个拓扑排序的模型,因为我们要计算一个点的状态是需要这个点前面相连的所有点的状态而来,因此很容易想到拓扑排序 阅读全文

posted @ 2024-08-12 20:34 swj2529411658 阅读(28) 评论(0) 推荐(0)

上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 17 下一页

导航