![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
恁村扛把子
这个作者很懒,什么都没留下…
展开
-
快速排序的五种优化(高频面试)
快速排序的五种优化(高频面试) 未优化 void quick_sort_v1(int *arr, int l, int r) { if (l >= r) return ; int x = l, y = r, z = arr[l]; while (x < y) { while (x < y && arr[y] >= z) --y; if (x < y) arr[x++] = arr[y]; w原创 2021-03-14 10:15:49 · 253 阅读 · 2 评论 -
高精度阶乘
高精度阶乘: 每一个大数都将存在ans数组中,ans[0]始终存的是得到的阶乘数的位数; #include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<iomanip> #include<algorithm> #include<...原创 2019-12-24 00:34:41 · 110 阅读 · 0 评论 -
高精度快速幂
高精度快速幂 a^n 类似大数阶乘的算法 代码: #include <iostream> using namespace std; int main() { int c[5002]; int n , a; c[0] = 1; c[1] = a; int di = 1; int num = 0; cin >> a>&...原创 2019-05-01 11:15:07 · 972 阅读 · 3 评论 -
大数相加
大数相加 就是小学学的加法运算规则 将数字串转换为字符串,相加逆序输出 代码如下: #include<iostream> using namespace std; #include<cstring> #define L 10000 string add(string a, string b) { string ans; int na[L], nb[L]; /...原创 2019-04-30 23:15:58 · 811 阅读 · 0 评论 -
大数阶乘
大数阶乘 话不多说上代码 #include <iostream> using namespace std; int main() { int c[50002]; int n; c[0] = 1; int di = 1; //位数出是为一 int num = 0; //进位初始为零 cin >> n; // 求n! fo...原创 2019-04-30 22:40:50 · 103 阅读 · 0 评论 -
acwing基础算法
文章目录基础算法快速排序归并排序整数二分浮点数二分高精度加法高精度减法高精度乘法高精度除法一维前缀和 —— 模板题二维前缀和 —— 模板题一维差分 —— 模板题二维差分 —— 模板题 基础算法 快速排序 void quick_sort(int q[], int l, int r) { if(l >= r)return; int i = l - 1, j = r + 1, x = q...原创 2019-11-29 00:32:45 · 6639 阅读 · 0 评论 -
分解合数的质因子
for(int i = 2; i <= n; i++) { // 暴力 int num = i; for(int j = 2; j * j <= num; j++) { if(num % j) continue; // 只要是素数就不进行下一步 while(num % j == 0) { // 分解合数的质数因子 ...原创 2019-11-29 00:30:48 · 366 阅读 · 0 评论