一.cf 764(dive3)补题:
764A:
可以
int MIN = INT_MAX; int MAX = INT_MIN;
省去了const int 一个很大或者很小的数,并且包括了边界值?反正这题用minn=0x3f3f3f不能ac,应该是边界值的问题,用了INT_MAX就ac了;
二.AcWing
1.复习了归并排序,了解了最后的两个while的原理;
#include <iostream>
using namespace std;
const int N = 1e5 + 10;
int a[N], tmp[N];
void merge_sort(int q[], int l, int r)
{
if (l >= r) return;
int mid = l + r >> 1;
merge_sort(q, l, mid), merge_sort(q, mid + 1, r);
int k = 0, i = l, j = mid + 1;
while (i <= mid && j <= r)
if (q[i] <= q[j]) tmp[k ++ ] = q[i ++ ];
else tmp[k ++ ] = q[j ++ ];
while (i <= mid) tmp[k ++ ] = q[i ++ ];
while (j <= r) tmp[k ++ ] = q[j ++ ];
for (i = l, j = 0; i <= r; i ++, j ++ ) q[i] = tmp[j];
}
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i ++ ) scanf("%d", &a[i]);
merge_sort(a, 0, n - 1);
for (int i = 0; i < n; i ++ ) printf("%d ", a[i]);
return 0;
}
2.二分法的原理,注意事项,模板!!
3.高精度加法模板;
//不压位代码
#include <iostream>
#include <vector>
using namespace std;
vector<int> add(vector<int> &A, vector<int> &B)
{
if (A.size() < B.size()) return add(B, A);
vector<int> C;
int t = 0;
for (int i = 0; i < A.size(); i ++ )
{
t += A[i];
if (i < B.size()) t += B[i];
C.push_back(t % 10);
t /= 10;
}
if (t) C.push_back(t);
return C;
}
int main()
{
string a, b;
vector<int> A, B;
cin >> a >> b;
for (int i = a.size() - 1; i >= 0; i -- ) A.push_back(a[i] - '0');
for (int i = b.size() - 1; i >= 0; i -- ) B.push_back(b[i] - '0');
auto C = add(A, B);
for (int i = C.size() - 1; i >= 0; i -- ) cout << C[i];
cout << endl;
return 0;
}
三.补oj题
新知识区: 1,static_cast<T>exphttps://blog.csdn.net/wucz122140729/article/details/105710011https://blog.csdn.net/wucz122140729/article/details/105710011 2,using 关键字(12条消息) C++中的using关键字_CL_XYZ-CSDN博客_using重命名https://blog.csdn.net/qq_33113661/article/details/89005098 3,signed main()(12条消息) 关于signed main()不报超时与int main()报超时_jucai_2的博客-CSDN博客https://blog.csdn.net/jucai_2/article/details/121090236 4,#ifdef DEBUG ? ?#endif 5,vector(12条消息) C++_vector操作_刘同学的博客-CSDN博客_vector操作https://blog.csdn.net/weixin_41743247/article/details/90635931 6,transform(12条消息) C++中的transform()函数_zhang___bo的博客-CSDN博客_c++transform函数https://blog.csdn.net/zhang___bo/article/details/119389457 7,isupper(12条消息) C语言isupper函数介绍、示例和实现_C语言技术网-码农有道-CSDN博客_isupper函数https://blog.csdn.net/wucz122140729/article/details/105710011
|