- 博客(7)
- 收藏
- 关注
原创 快排及其优化
#include<iostream>#include<cstdio>using namespace std;void quick_sort_v1(int *arr,int l,int r){ if (l >= r) { return; } int x = l,y = r,base = arr[l]; while(x < y){ while(x<y && arr[y] >= base) y--;.
2022-01-12 23:56:39
372
原创 二分查找算法
#include<iostream>#include<ctime>#include<cstdlib>#include<cstdio>using namespace std;int binary_search(int *arr,int n,int x){ int head = 0,tail = n-1, mid; while(head<=tail){ mid = (head+tail) >> 1;.
2022-01-11 16:06:25
164
原创 扩展欧几里得求二元一次方程
# include<stdio.h>int ex_gcd(int a,int b,int *x,int *y){ if(!b){ *x=1,*y=0; return a; } int xx,yy,ret=ex_gcd(b,a%b,&xx,&yy); *x=yy; *y=xx-a/b*yy; return ret;}int main(){ int a,b,x,y...
2021-11-30 22:31:49
535
原创 欧几里得算法
# include<stdio.h>int gcd(int a,int b){ return(b?gcd(b,a%b):a);}int main(){ int a,b; while(~scanf("%d%d",&a,&b)){ printf("gcd(%d,%d)=%d",a,b,gcd(a,b)); } return 0;}
2021-11-29 11:30:49
385
原创 高精度减法
#include<iostream>using namespace std;int n1[1005], n2[1005], ans[1005], n, m;char s1[1005], s2[1005];void func(int *n1, int *n2, int n, int m) { for (int i = 0; i <= n; i++) { for (int j = 0; j <= m; j++) { if (n.
2021-11-26 12:09:08
533
原创 高精度乘法
#include<iostream>#include<cstring>using namespace std;int n1[1005],n2[1005],ans[1005];char s1[1005],s2[1005];int main(){ cin >> s1 >> s2; n1[0] = strlen(s1); for(int i=0,j=n1[0]; i<n1[0]; i++,j--){...
2021-11-22 21:01:37
84
原创 高精度加法
#include<iostream>#include<cstring>using namespace std;int n1[1005],n2[1005],ans[1005];char s1[1005],s2[1005];//将数据读入字符串,防止超过int或long等类型的最大值int main(){ cin >> s1 >> s2; n1[0] =strlen(s1); for(int i=0, j=n1[0]; i&l...
2021-11-22 19:44:45
422
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人