算法-算法基础
算法-算法基础
竹子二分法
整数二分
1 | bool chekk(int x) |
浮点数二分
1 | bool check(double x) |
高精度算法
高精度数字的读入
1 | void clear(int a[]) |
高精度数字的输出
1 | void print(int a[]) |
高精度加法
1 | void add(int a[], int b[], int c[]) |
使用 vector 写法:
1 | vector<int> add(vector<int> A, vector<int> B) |
高精度减法
1 | void sub(int a[], int b[], int c[]) |
使用 vector 写法:
1 | bool cmp(vector<int> &a, vector<int> &b) { |
高精度乘法
单精度 × 高精度
1 | void mul_short(int a[], int b, int c[]) |
使用 vector 写法:
1 | vector<int> mul(vector<int> A, int b) { |
高精度 × 高精度
1 | void mul(int a[], int b[], int c[]) |
使用 vector 写法:
1 | vector<int> mul(vector<int> &A, vector<int> &B) { |
高精度除法
1 | vector<int> div(vector<int> &A, ll b, ll &r) { |
排序
快速排序
1 | void quick_sort(int q[], int l, int r) |
归并排序
1 | void merge_sort(int q[], int l, int r) |
sscanf 和 sprintf 洛谷P1957
sscanf语句
- 第一个参数为字符数组、第二个参数为字符串格式、后边的参数为字符串中对应分解的部分进行输出到具体变量。
sprintf语句
- 第一个参数为字符数组、第二个参数为字符串格式、后边的参数为将具体的变量合并到字符串中。



